Sha256: 01a593a5292967e645db009a3f6151c1135913ef8c958156ecf1b627df26e8f1

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

require 'active_record'

module AdaptiveAlias
  module ActiveModelPatches
    module WriteAttribute
      def write_attribute(attr_name, value)
        name = attr_name.to_s
        name = self.class.attribute_aliases[name] || name
        super(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
        super(name, value)
      end
    end
  end
end

module ActiveRecord::AttributeMethods::Write
  prepend AdaptiveAlias::ActiveModelPatches::WriteAttribute
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adaptive_alias-0.2.0 lib/adaptive_alias/active_model_patches/write_attribute.rb