#primary_key (readonly)
[ GitHub ]# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 20
delegate :table_name, :column_names, :primary_key, :attribute_types, to: :base_klass
123456789_123456789_123456789_123456789_123456789_
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
|
|
| Inherits: | Object |
| Defined in: | activerecord/lib/active_record/associations/join_dependency/join_part.rb |
A JoinPart represents a part of a ::ActiveRecord::Associations::JoinDependency. It is inherited by JoinBase and JoinAssociation. A JoinBase represents the Active Record which everything else is being joined onto. A JoinAssociation represents an association which is joining to the base. A JoinAssociation may result in more than one actual join operations (for example a has_and_belongs_to_many JoinAssociation would result in two; one for the join table and one for the target table).
The Active Record class which this join part is associated ‘about’; for a JoinBase this is the actual base model, for a JoinAssociation this is the target model of the association.
The Active Record class which this join part is associated ‘about’; for a JoinBase this is the actual base model, for a JoinAssociation this is the target model of the association.
::Enumerable - Included| #many? | Returns |
An ::Arel::Table for the active_record.
::Enumerable - Included| #compact_blank | Returns a new |
| #exclude? | The negative of the |
| #excluding | Returns a copy of the enumerable excluding the specified elements. |
| #in_order_of | Returns a new |
| #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 | Alias for Enumerable#excluding. |
| #as_json | |
::ActiveSupport::EnumerableCoreExt::Constants - IncludedJoinPart
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 22
def initialize(base_klass, children) @base_klass = base_klass @children = children end
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 20
delegate :table_name, :column_names, :primary_key, :attribute_types, to: :base_klass
The Active Record class which this join part is associated ‘about’; for a JoinBase this is the actual base model, for a JoinAssociation this is the target model of the association.
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 18
attr_reader :base_klass, :children
The Active Record class which this join part is associated ‘about’; for a JoinBase this is the actual base model, for a JoinAssociation this is the target model of the association.
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 18
attr_reader :base_klass, :children
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 20
delegate :table_name, :column_names, :primary_key, :attribute_types, to: :base_klass
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 20
delegate :table_name, :column_names, :primary_key, :attribute_types, to: :base_klass
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 20
delegate :table_name, :column_names, :primary_key, :attribute_types, to: :base_klass
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 31
def each(&block) yield self children.each { |child| child.each(&block) } end
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 48
def extract_record(row, column_names_with_alias) # This code is performance critical as it is called per row. # see: https://github.com/rails/rails/pull/12185 hash = {} index = 0 length = column_names_with_alias.length while index < length column = column_names_with_alias[index] hash[column.name] = row[column.alias] index += 1 end hash end
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 65
def instantiate(row, aliases, column_types = {}, &block) base_klass.instantiate(extract_record(row, aliases), column_types, &block) end
Boolean
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 27
def match?(other) self.class == other.class end
An ::Arel::Table for the active_record
# File 'activerecord/lib/active_record/associations/join_dependency/join_part.rb', line 44
def table raise NotImplementedError end