Class: PtabModel

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

Direct Known Subclasses

PtabTrial

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PtabModel

Returns a new instance of PtabModel.



87
88
89
90
91
92
93
94
# File 'lib/ptab.rb', line 87

def initialize(data)
    inflector = Dry::Inflector.new
    data.each {|key, value| 
        underscore_key = inflector.underscore(key)
        instance_variable_set("@#{underscore_key}", value)
        self.class.send(:attr_reader, underscore_key) # Dynamically create an accessor
    }
end

Class Method Details

.objectsObject



96
97
98
# File 'lib/ptab.rb', line 96

def self.objects
    @objects
end