Module: PropertySets::ActiveRecordExtension::InstanceMethods

Defined in:
lib/property_sets/active_record_extension.rb

Instance Method Summary collapse

Instance Method Details

#update_attributes(attributes) ⇒ Object


166
167
168
169
# File 'lib/property_sets/active_record_extension.rb', line 166

def update_attributes(attributes)
  update_property_set_attributes(attributes)
  super
end

#update_attributes!(attributes) ⇒ Object


171
172
173
174
# File 'lib/property_sets/active_record_extension.rb', line 171

def update_attributes!(attributes)
  update_property_set_attributes(attributes)
  super
end

#update_property_set_attributes(attributes) ⇒ Object


176
177
178
179
180
181
182
183
184
# File 'lib/property_sets/active_record_extension.rb', line 176

def update_property_set_attributes(attributes)
  if attributes && self.class.property_set_index.any?
    self.class.property_set_index.each do |property_set|
      if property_set_hash = attributes.delete(property_set)
        send(property_set).set(property_set_hash, true)
      end
    end
  end
end