123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Key

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: activerecord/lib/active_record/key.rb

Class Method Summary

Instance Attribute Summary

::Enumerable - Included

#many?

Returns true if the enumerable has more than 1 element.

Instance Method Summary

::Enumerable - Included

#compact_blank

Returns a new ::Array without the blank items.

#exclude?

The negative of the Enumerable#include?.

#excluding

Returns a copy of the enumerable excluding the specified elements.

#in_order_of

Returns a new ::Array where the order has been set to that provided in the series, based on the key of the objects in the original enumerable.

#including

Returns a new array that includes the passed elements.

#index_by

Convert an enumerable to a hash, using the block result as the key and the element as the value.

#index_with

Convert an enumerable to a hash, using the element as the key and the block result as the value.

#maximum

Calculates the maximum from the extracted elements.

#minimum

Calculates the minimum from the extracted elements.

#pick

Extract the given key from the first element in the enumerable.

#pluck

Extract the given key from each element in the enumerable.

#sole

Returns the sole item in the enumerable.

#without
#as_json

::ActiveSupport::EnumerableCoreExt::Constants - Included

Class Method Details

.for(name)

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 7

def self.for(name)
  case name
  when Array
    Composite.new(name)
  when nil, false
    None.new
  else
    Single.new(name)
  end
end

Instance Attribute Details

#columns (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 18

attr_reader :name, :columns

#composite?Boolean (readonly)

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 50

def composite?
  raise NotImplementedError
end

#name (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 18

attr_reader :name, :columns

#present?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 20

def present?
  !@columns.empty?
end

Instance Method Details

#==(other) Also known as: #eql?

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 41

def ==(other)
  other.is_a?(Key) && name == other.name
end

#arel_columns(table)

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 58

def arel_columns(table)
  raise NotImplementedError
end

#cast(values, model)

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 62

def cast(values, model)
  raise NotImplementedError
end

#each(&block)

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 24

def each(&block)
  @columns.each(&block)
end

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 44

alias_method :eql?, :==

#expects_multiple_ids?(value) ⇒ Boolean

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 70

def expects_multiple_ids?(value)
  raise NotImplementedError
end

#hash

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 46

def hash
  name.hash
end

#inferred_id

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 74

def inferred_id
  raise NotImplementedError
end

#length Also known as: #size

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 28

def length
  @columns.length
end

#size

Alias for #length.

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 31

alias_method :size, :length

#to_a

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 33

def to_a
  @columns
end

#to_s

[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 37

def to_s
  @name.to_s
end

#value_of(record)

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 66

def value_of(record)
  raise NotImplementedError
end

#where_clauses(values)

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 78

def where_clauses(values)
  raise NotImplementedError
end

#where_hash(values)

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/key.rb', line 54

def where_hash(values)
  raise NotImplementedError
end