Class: AxTrack::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/ax_track/object.rb

Instance Method Summary collapse

Instance Method Details

#create_getters(required_getter_methods = instance_variables.map { |attr_name| attr_name[1..-1 ]}) ⇒ Object

pass in an array for getters which should be generated. if nothing is passed in, it will create an instance variable for all instance variables.



8
9
10
11
12
13
14
15
# File 'lib/ax_track/object.rb', line 8

def create_getters(required_getter_methods = instance_variables.map { |attr_name| attr_name[1..-1 ]})
  required_getter_methods.each do |attr|
    singleton_class.send :attr_reader, attr unless self.respond_to? attr
    # define_singleton_method(v.to_s.tr('@','')) do
    #   instance_variable_get(v)
    # end
  end
end