Class: AttrAccessorObject

Inherits:
Object
  • Object
show all
Defined in:
lib/railz_lite/models/attr_accessor_object.rb

Class Method Summary collapse

Class Method Details

.my_attr_accessor(*names) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/railz_lite/models/attr_accessor_object.rb', line 2

def self.my_attr_accessor(*names)
  names.each do |name|
    ivar = "@#{name}"
    define_method(name) do 
      instance_variable_get(ivar)
    end
    define_method("#{name}=") do |val|
      instance_variable_set(ivar, val)
    end
  end
end