Module: BelongsToHstore::Association
- Extended by:
- ActiveSupport::Concern
- Includes:
- HstoreQueryHelper
- Defined in:
- lib/belongs_to_hstore/association.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#read_attribute(attr_name) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/belongs_to_hstore/association.rb', line 36 def read_attribute(attr_name) if attr_type = self.class.belongs_to_hstore_attributes[attr_name] attr_value = send(attr_name) if attr_type == Integer attr_value = (attr_value.is_a?(String) && attr_value.empty?) ? nil : attr_value.to_i end attr_value else super end end |
#write_attribute(attr_name, attr_value) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/belongs_to_hstore/association.rb', line 48 def write_attribute(attr_name, attr_value) if self.class.belongs_to_hstore_attributes[attr_name] send("#{attr_name}=", attr_value.to_s) else super end end |