Sha256: 7b29c01f13efc9ecf701f483ead46dde267e291e74b438364d8e54239b7157d9
Contents?: true
Size: 906 Bytes
Versions: 8
Compression:
Stored size: 906 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 self.attribute_names.inject({}) do |attrs, name| attrs[name] = read_attribute_before_type_cast(name) attrs end 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
8 entries across 8 versions & 1 rubygems