Class: SQLConstructor::BasicJoin
- Inherits:
-
GenericQuery
- Object
- SQLObject
- GenericQuery
- SQLConstructor::BasicJoin
- Defined in:
- lib/sqlconstructor.rb
Overview
Internal class which represents a basic JOIN statement.
Direct Known Subclasses
Constant Summary collapse
- METHODS =
{ :on => QAttr.new( :name => 'join_on', :text => 'ON', :val => SQLConditional ), :using => QAttr.new( :name => 'join_using', :text => 'USING', :val => SQLObject ), }
Instance Attribute Summary collapse
-
#join_on ⇒ Object
Returns the value of attribute join_on.
-
#join_sources ⇒ Object
Returns the value of attribute join_sources.
-
#join_using ⇒ Object
Returns the value of attribute join_using.
Attributes inherited from GenericQuery
#attr_index_hints, #caller, #child_caller, #dialect, #exporter, #string, #tidy, #type
Attributes inherited from SQLObject
#alias, #inline, #name, #separator
Instance Method Summary collapse
-
#initialize(_caller, type, *sources) ⇒ BasicJoin
constructor
Class contructor.
-
#join_more(*sources) ⇒ Object
Adds more sources to @join_sources list.
-
#to_s ⇒ Object
Export to string with sources aliases.
Methods inherited from GenericQuery
#_get, #_remove, #method_missing, #to_str
Methods inherited from SQLObject
#_name, #_string, #_string=, get
Constructor Details
#initialize(_caller, type, *sources) ⇒ BasicJoin
Class contructor. Takes a caller object as the first argument, JOIN
type as the second argument, and a list of sources for the JOIN clause
446 447 448 449 450 451 452 |
# File 'lib/sqlconstructor.rb', line 446 def initialize ( _caller, type, *sources ) type = type.to_s type.upcase!.gsub! /_/, ' ' super _caller @type = type @join_sources = SQLAliasedList.new *sources end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SQLConstructor::GenericQuery
Instance Attribute Details
#join_on ⇒ Object
Returns the value of attribute join_on.
435 436 437 |
# File 'lib/sqlconstructor.rb', line 435 def join_on @join_on end |
#join_sources ⇒ Object
Returns the value of attribute join_sources.
435 436 437 |
# File 'lib/sqlconstructor.rb', line 435 def join_sources @join_sources end |
#join_using ⇒ Object
Returns the value of attribute join_using.
435 436 437 |
# File 'lib/sqlconstructor.rb', line 435 def join_using @join_using end |
Instance Method Details
#join_more(*sources) ⇒ Object
Adds more sources to @join_sources list
457 458 459 |
# File 'lib/sqlconstructor.rb', line 457 def join_more ( *sources ) @join_sources.push *sources end |
#to_s ⇒ Object
Export to string with sources aliases
464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/sqlconstructor.rb', line 464 def to_s return @string if @string result = @type + " " arr = [ ] @join_sources.each do |src| _alias = src.alias ? " " + src.alias.to_s : "" str = src.to_s + _alias arr << str end result += arr.join ',' result += @exporter.separator result += "ON " + @join_on.val.to_s if @join_on @string = result end |