Sha256: da829958b2be4c2e5e507f18a0c6c974f6421bdba2d6be6f5f2647522ec7ec3d
Contents?: true
Size: 713 Bytes
Versions: 1
Compression:
Stored size: 713 Bytes
Contents
require 'active_record' module ActiveRecord::AttributeMethods::Write def write_attribute(attr_name, value) name = attr_name.to_s name = self.class.attribute_aliases[name] || name name = @primary_key if name == 'id' && @primary_key _write_attribute(name, value) end # This method exists to avoid the expensive primary_key check internally, without # breaking compatibility with the write_attribute API def _write_attribute(attr_name, value) # :nodoc: name = attr_name.to_s name = self.class.attribute_aliases[name] || name sync_with_transaction_state if @transaction_state&.finalized? @attributes.write_from_user(name, value) value end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
adaptive_alias-0.1.0 | lib/adaptive_alias/active_model_patches/write_attribute.rb |