Module: Recliner::AttributeMethods::BeforeTypeCast

Extended by:
ActiveSupport::Concern
Defined in:
lib/recliner/attribute_methods/before_type_cast.rb

Instance Method Summary collapse

Instance Method Details

#attributes_before_type_castObject

Returns a hash of attributes before typecasting.



22
23
24
# File 'lib/recliner/attribute_methods/before_type_cast.rb', line 22

def attributes_before_type_cast
  @attributes_before_type_cast ||= {}.with_indifferent_access
end

#read_attribute_before_type_cast(name) ⇒ Object

Returns an attribute value before typecasting.



13
14
15
16
17
18
19
# File 'lib/recliner/attribute_methods/before_type_cast.rb', line 13

def read_attribute_before_type_cast(name)
  if prop = property(name)
    attributes_before_type_cast[prop.as]
  else
    attributes_before_type_cast[name.to_s]
  end
end

#write_attribute(name, value) ⇒ Object

:nodoc:



26
27
28
29
30
31
32
33
34
# File 'lib/recliner/attribute_methods/before_type_cast.rb', line 26

def write_attribute(name, value)#:nodoc:
  if prop = property(name)
    attributes_before_type_cast[prop.as] = value
  else
    attributes_before_type_cast[name.to_s] = value
  end
  
  super
end