Sha256: 66f9cf8211adf6095dce1346b89ef98ea0c90926630a220e2d0a08eff8209dd9
Contents?: true
Size: 850 Bytes
Versions: 36
Compression:
Stored size: 850 Bytes
Contents
module ActiveRecord module AttributeMethods module BeforeTypeCast extend ActiveSupport::Concern included do attribute_method_suffix "_before_type_cast" end def read_attribute_before_type_cast(attr_name) @attributes[attr_name] end # Returns a hash of attributes before typecasting and deserialization. def attributes_before_type_cast Hash[attribute_names.map { |name| [name, read_attribute_before_type_cast(name)] }] end private # Handle *_before_type_cast for method_missing. def attribute_before_type_cast(attribute_name) if attribute_name == 'id' read_attribute_before_type_cast(self.class.primary_key) else read_attribute_before_type_cast(attribute_name) end end end end end
Version data entries
36 entries across 36 versions & 2 rubygems