Sha256: 7d6fb7801e92be00aba72db0db395f4ec72ca25af683ff0ee1bd4f974e1b81c9

Contents?: true

Size: 458 Bytes

Versions: 7

Compression:

Stored size: 458 Bytes

Contents

module ActiveRecord
  module AttributeMethods
    module Read
      rails_read_attribute = instance_method(:read_attribute)
      define_method(:read_attribute) do |attr_name|
        if attr_name.kind_of?(Array)
          attr_name.map {|name| read_attribute(name)}.to_composite_keys
        else
          rails_read_attribute.bind(self).(attr_name)
        end
      end
    end
  end
end

ActiveRecord::Base.class_eval do
  alias :[] :read_attribute
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.9 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-7.0.8 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-7.0.7 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-7.0.6 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-7.0.5 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-7.0.4 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-7.0.3 lib/composite_primary_keys/attribute_methods/read.rb