Module: PropertySets::ActiveRecordExtension::InstanceMethods
- Defined in:
- lib/property_sets/active_record_extension.rb
Instance Method Summary collapse
- #update(attributes) ⇒ Object (also: #update_attributes)
- #update!(attributes) ⇒ Object (also: #update_attributes!)
- #update_columns(attributes) ⇒ Object
- #update_property_set_attributes(attributes) ⇒ Object
Instance Method Details
#update(attributes) ⇒ Object Also known as: update_attributes
192 193 194 195 |
# File 'lib/property_sets/active_record_extension.rb', line 192 def update(attributes) update_property_set_attributes(attributes) super end |
#update!(attributes) ⇒ Object Also known as: update_attributes!
198 199 200 201 |
# File 'lib/property_sets/active_record_extension.rb', line 198 def update!(attributes) update_property_set_attributes(attributes) super end |
#update_columns(attributes) ⇒ Object
214 215 216 217 218 219 220 |
# File 'lib/property_sets/active_record_extension.rb', line 214 def update_columns(attributes) if delegated_property_sets? attributes = attributes.reject { |k, _| self.class.delegated_property_set_attributes.include?(k.to_s) } end super end |
#update_property_set_attributes(attributes) ⇒ Object
204 205 206 207 208 209 210 211 212 |
# File 'lib/property_sets/active_record_extension.rb', line 204 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 |