module PropertySets::ActiveRecordExtension::InstanceMethods

Public Instance Methods

update(attributes) click to toggle source
Calls superclass method
# File lib/property_sets/active_record_extension.rb, line 192
def update(attributes)
  update_property_set_attributes(attributes)
  super
end
Also aliased as: update_attributes
update!(attributes) click to toggle source
Calls superclass method
# File lib/property_sets/active_record_extension.rb, line 198
def update!(attributes)
  update_property_set_attributes(attributes)
  super
end
Also aliased as: update_attributes!
update_attributes(attributes)
Alias for: update
update_attributes!(attributes)
Alias for: update!
update_columns(attributes) click to toggle source
Calls superclass method
# 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) click to toggle source
# 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

Private Instance Methods

attributes_for_create(attribute_names) click to toggle source
Calls superclass method
# File lib/property_sets/active_record_extension.rb, line 228
def attributes_for_create(attribute_names)
  super(filter_delegated_property_set_attributes(attribute_names))
end
attributes_for_update(attribute_names) click to toggle source
Calls superclass method
# File lib/property_sets/active_record_extension.rb, line 232
def attributes_for_update(attribute_names)
  super(filter_delegated_property_set_attributes(attribute_names))
end
delegated_property_sets?() click to toggle source
# File lib/property_sets/active_record_extension.rb, line 224
def delegated_property_sets?
  self.class.respond_to?(:delegated_property_set_attributes)
end
filter_delegated_property_set_attributes(attribute_names) click to toggle source
# File lib/property_sets/active_record_extension.rb, line 236
def filter_delegated_property_set_attributes(attribute_names)
  if delegated_property_sets?
    return attribute_names - self.class.delegated_property_set_attributes.to_a
  end
  attribute_names
end