Class: Joiner::Joins
- Inherits:
-
Object
- Object
- Joiner::Joins
- Defined in:
- lib/joiner/joins.rb
Constant Summary collapse
- ACTIVE_RECORD_VERSION =
Gem::Version.new(ActiveRecord::VERSION::STRING)
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #add_join_to(path) ⇒ Object
- #alias_for(path) ⇒ Object
-
#initialize(model) ⇒ Joins
constructor
A new instance of Joins.
- #join_values ⇒ Object
Constructor Details
#initialize(model) ⇒ Joins
Returns a new instance of Joins.
9 10 11 12 |
# File 'lib/joiner/joins.rb', line 9 def initialize(model) @model = model @joins_cache = Set.new end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/joiner/joins.rb', line 7 def model @model end |
Instance Method Details
#add_join_to(path) ⇒ Object
14 15 16 17 18 |
# File 'lib/joiner/joins.rb', line 14 def add_join_to(path) return if path.empty? joins_cache.add path_as_hash(path) end |
#alias_for(path) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/joiner/joins.rb', line 20 def alias_for(path) return model.table_name if path.empty? add_join_to path association_for(path).tables.first.name end |
#join_values ⇒ Object
27 28 29 30 31 |
# File 'lib/joiner/joins.rb', line 27 def join_values Joiner::JoinDependency.new( model, table, joins_cache.to_a, Arel::Nodes::OuterJoin ) end |