Sha256: 3fdf3b7f15f24e13f508384c144e655ccbdd9d42d4259c3ae29d652ac4cf30af

Contents?: true

Size: 689 Bytes

Versions: 3

Compression:

Stored size: 689 Bytes

Contents

module ActiveRecord
  module AttributeMethods
    module Read
      def read_attribute(attr_name, &block)
        # CPK
        if attr_name.kind_of?(Array)
          _read_attribute(attr_name, &block)
        else
          name = attr_name.to_s
          name = self.class.primary_key if name == 'id'.freeze
          _read_attribute(name, &block)
        end
      end

      def _read_attribute(attr_name)
        # CPK
        if attr_name.kind_of?(Array)
          attr_name.map {|name| @attributes.fetch_value(name.to_s)}
        else
          @attributes.fetch_value(attr_name.to_s) { |n| yield n if block_given? }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
composite_primary_keys-8.1.4 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-8.1.3 lib/composite_primary_keys/attribute_methods/read.rb
composite_primary_keys-8.1.2 lib/composite_primary_keys/attribute_methods/read.rb