Sha256: 934583b15947c472224291cef86d8cf12da9a7907fce1f76fbb81339fdb173ba
Contents?: true
Size: 1021 Bytes
Versions: 2
Compression:
Stored size: 1021 Bytes
Contents
module ActiveRecord module AttributeMethods module Write def write_attribute_with_type_cast(attr_name, value, should_type_cast) # CPK if attr_name.kind_of?(Array) value = [nil]*attr_name.length if value.nil? unless value.length == attr_name.length raise "Number of attr_names #{attr_name.inspect} and values #{value.inspect} do not match" end [attr_name, value].transpose.map {|name,val| write_attribute(name, val)} value else attr_name = attr_name.to_s # CPK # attr_name = self.class.primary_key if attr_name == 'id' && self.class.primary_key attr_name = self.class.primary_key if attr_name == 'id' && self.class.primary_key && !self.composite? if should_type_cast @attributes.write_from_user(attr_name, value) else @attributes.write_from_database(attr_name, value) end value end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
composite_primary_keys-8.1.0 | lib/composite_primary_keys/attribute_methods/write.rb |
composite_primary_keys-8.0.0 | lib/composite_primary_keys/attribute_methods/write.rb |