Class: PluckMap::Relationships::AbstractOwner

Inherits:
Struct
  • Object
show all
Defined in:
lib/pluck_map/relationships.rb

Overview

ActiveRecord constructs an Association from a Reflection and an Owner. It expects Owner to be an instance of an ActiveRecord object and uses ‘[]` to access specific values for fields on the record.

e.g. WHERE books.author_id = 7

We want to create a subquery that will reference those fields but not their specific values.

e.g. WHERE books.author_id = authors.id

So we create an object that serves the purpose of Owner but returns appropriate selectors.

Instance Method Summary collapse

Instance Method Details

#[](value) ⇒ Object



82
83
84
# File 'lib/pluck_map/relationships.rb', line 82

def [](value)
  self.class.arel_table[value]
end

#classObject



78
79
80
# File 'lib/pluck_map/relationships.rb', line 78

def class
  reflection.active_record
end