Module: PropertySets::ActiveRecordExtension::InstanceMethods

Defined in:
lib/property_sets/active_record_extension.rb

Instance Method Summary collapse

Instance Method Details

#update(attributes) ⇒ Object Also known as: update_attributes



200
201
202
203
# File 'lib/property_sets/active_record_extension.rb', line 200

def update(attributes)
  update_property_set_attributes(attributes)
  super
end

#update!(attributes) ⇒ Object Also known as: update_attributes!



206
207
208
209
# File 'lib/property_sets/active_record_extension.rb', line 206

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

#update_columns(attributes) ⇒ Object



222
223
224
225
226
227
228
# File 'lib/property_sets/active_record_extension.rb', line 222

def update_columns(attributes)
  if delegated_property_sets?
    attributes = attributes.reject{|k,_| self.class.delegated_property_set_attributes.include?(k.to_s) }
  end

  super attributes
end

#update_property_set_attributes(attributes) ⇒ Object



212
213
214
215
216
217
218
219
220
# File 'lib/property_sets/active_record_extension.rb', line 212

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