Module: Tire::Model::DynamicPersistence
- Defined in:
- lib/tire/model/dynamic_persistence/dynamic_persistence.rb
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Object
Overrides the initializer in Tire::Model::Persistence to allow dynamic creation of attributes without the need to declare them with ‘property :name`.
Instance Method Details
#initialize(attrs = {}) ⇒ Object
Overrides the initializer in Tire::Model::Persistence to allow
dynamic creation of attributes without the need to
declare them with `property :name`
11 12 13 14 15 16 17 18 19 |
# File 'lib/tire/model/dynamic_persistence/dynamic_persistence.rb', line 11 def initialize(attrs={}) attrs.each do |attr, value| # => call Tire's property method if it's declared for this attribute self.class.property attr unless self.class.property_types.keys.include? attr # => set instance variable for this attribute instance_variable_set("@#{attr}", value) end super attrs end |