Module: ActiveLayer::Attributes::InstanceMethods

Defined in:
lib/active_layer/attributes.rb

Instance Method Summary collapse

Instance Method Details

#active_layer_attributes_setting(new_attributes) ⇒ Object

override persistence saving to pull in the guard functionality



51
52
53
# File 'lib/active_layer/attributes.rb', line 51

def active_layer_attributes_setting(new_attributes)
  attributes = new_attributes
end

#attributes=(new_attributes) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_layer/attributes.rb', line 35

def attributes=(new_attributes)
  return if new_attributes.nil?
  attributes = new_attributes.stringify_keys

  safe_attributes = if accessible_attributes.nil? 
    attributes
  else
    attributes.reject { |key, value| !accessible_attributes.include?(key.gsub(/\(.+/, "")) }
  end
  
  safe_attributes.each do |k, v|
    respond_to?(:"#{k}=") ? send(:"#{k}=", v) : raise(UnknownAttributeError, "unknown attribute: #{k}")
  end
end