Class: JoinClause
- Defined in:
- lib/activeleopard/query_clauses/join_clause.rb
Instance Attribute Summary collapse
-
#assoc_options ⇒ Object
readonly
Returns the value of attribute assoc_options.
-
#source_table ⇒ Object
readonly
Returns the value of attribute source_table.
Instance Method Summary collapse
- #as_sql ⇒ Object
-
#initialize(assoc_options, source_table) ⇒ JoinClause
constructor
A new instance of JoinClause.
- #on_clause ⇒ Object
- #other_table ⇒ Object
Constructor Details
#initialize(assoc_options, source_table) ⇒ JoinClause
Returns a new instance of JoinClause.
4 5 6 7 8 9 10 11 |
# File 'lib/activeleopard/query_clauses/join_clause.rb', line 4 def initialize(, source_table) unless raise InvalidInput, "Argument must be an association(type: symbol)" end @assoc_options = @source_table = source_table end |
Instance Attribute Details
#assoc_options ⇒ Object (readonly)
Returns the value of attribute assoc_options.
26 27 28 |
# File 'lib/activeleopard/query_clauses/join_clause.rb', line 26 def @assoc_options end |
#source_table ⇒ Object (readonly)
Returns the value of attribute source_table.
26 27 28 |
# File 'lib/activeleopard/query_clauses/join_clause.rb', line 26 def source_table @source_table end |
Instance Method Details
#as_sql ⇒ Object
22 23 24 |
# File 'lib/activeleopard/query_clauses/join_clause.rb', line 22 def as_sql "JOIN #{other_table} ON #{on_clause} " end |
#on_clause ⇒ Object
17 18 19 20 |
# File 'lib/activeleopard/query_clauses/join_clause.rb', line 17 def on_clause "#{source_table}.#{.own_join_column}" + " = " + "#{other_table}.#{.other_join_column}" end |
#other_table ⇒ Object
13 14 15 |
# File 'lib/activeleopard/query_clauses/join_clause.rb', line 13 def other_table .table_name end |