module Property::Attribute::InstanceMethods

Public Instance Methods

prop()
Alias for: properties
prop=(new_properties)
Alias for: properties=
properties() click to toggle source
# File lib/property/attribute.rb, line 84
def properties
  @properties ||= load_properties
end
Also aliased as: prop
properties=(new_properties) click to toggle source

Define a set of properties. This acts like ‘attributes=’: it merges the current properties with the list of provided key/values. Note that unlike ‘attributes=’, the keys must be provided as strings, not symbols. For efficiency reasons and simplification of the API, we do not convert from symbols.

# File lib/property/attribute.rb, line 94
def properties=(new_properties)
  return if new_properties.nil?
  properties.merge!(new_properties)
end
Also aliased as: prop=
reload_properties!() click to toggle source

Force a reload of the properties from the ones stored in the database.

# File lib/property/attribute.rb, line 102
def reload_properties!
  @properties = load_properties
end

Private Instance Methods

attributes_with_properties=(attributes, guard_protected_attributes = true) click to toggle source
# File lib/property/attribute.rb, line 107
def attributes_with_properties=(attributes, guard_protected_attributes = true)
  property_columns = schema.column_names

  model_attrs  = {}

  attributes.keys.each do |k|
    if respond_to?("#{k}=")
      model_attrs[k] = attributes.delete(k)
    end
  end

  # Properties validation will add errors on invalid keys.
  self.properties = attributes
  self.attributes_without_properties = model_attrs
end