module ScopedAttrAccessor
This module adds scoped accessor methods to a Ruby Class. For example:
class Foo extend ScopedAttrAccessor private_attr_reader :thing1, :thing2, :thing3 protected_attr_writer :counter protected_attr_accessor :flagbag end
They work exactly the same as the regular ruby attr_accessor methods, except they are placed in the appropriate public or private scope as desired.
Constants
- VERSION
Public Instance Methods
private_attr_accessor(*names)
click to toggle source
# File lib/scoped_attr_accessor.rb, line 27 def private_attr_accessor(*names) private_attr_reader(*names) private_attr_writer(*names) end
private_attr_reader(*names)
click to toggle source
# File lib/scoped_attr_accessor.rb, line 17 def private_attr_reader(*names) attr_reader(*names) private(*names) end
private_attr_writer(*names)
click to toggle source
# File lib/scoped_attr_accessor.rb, line 22 def private_attr_writer(*names) attr_writer(*names) private(*names.map {|name| "#{name}="}) end
protected_attr_accessor(*names)
click to toggle source
# File lib/scoped_attr_accessor.rb, line 42 def protected_attr_accessor(*names) protected_attr_reader(*names) protected_attr_writer(*names) end
protected_attr_reader(*names)
click to toggle source
# File lib/scoped_attr_accessor.rb, line 32 def protected_attr_reader(*names) attr_reader(*names) protected(*names) end
protected_attr_writer(*names)
click to toggle source
# File lib/scoped_attr_accessor.rb, line 37 def protected_attr_writer(*names) attr_writer(*names) protected(*names.map {|name| "#{name}="}) end