Class: Babik::QuerySet::SetOperation
- Inherits:
-
AbstractBase
- Object
- AbstractBase
- Babik::QuerySet::SetOperation
- Defined in:
- lib/babik/queryset.rb
Overview
Each one of the set operations that can be executed in SQL
Instance Attribute Summary collapse
-
#left_operand ⇒ Object
readonly
Returns the value of attribute left_operand.
-
#right_operand ⇒ Object
readonly
Returns the value of attribute right_operand.
Attributes inherited from AbstractBase
#_aggregation, #_count, #_distinct, #_limit, #_lock_type, #_order, #_projection, #_select_related, #_where, #model
Instance Method Summary collapse
-
#initialize(model, left_operand, right_operand) ⇒ SetOperation
constructor
A new instance of SetOperation.
- #operation ⇒ Object
Methods inherited from AbstractBase
_execute_sql, #all, #each, #left_joins_by_alias
Methods included from Updatable
Methods included from Sortable
#disorder!, #invert_order!, #order!, #order_by!, #ordered?
Methods included from SetOperations
#difference, #intersection, #union
Methods included from RelatedSelector
Methods included from SQLRenderizable
Methods included from Projectable
#project!, #projection?, #unproject!
Methods included from Lockable
Methods included from Limitable
#[], #exists?, #fetch, #limit!, #limit?, #unlimit!
Methods included from Filterable
Methods included from Distinguishable
Methods included from NoneQuerySet
Methods included from Deletable
Methods included from Countable
#count, #empty?, #exists?, #length, #size
Methods included from Clonable
#clone, #method_missing, #mutate_clone, #respond_to_missing?
Methods included from Bounded
#earliest, #first, #last, #latest
Methods included from Aggregatable
Constructor Details
#initialize(model, left_operand, right_operand) ⇒ SetOperation
Returns a new instance of SetOperation.
130 131 132 133 134 |
# File 'lib/babik/queryset.rb', line 130 def initialize(model, left_operand, right_operand) @left_operand = left_operand @right_operand = right_operand super(model) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Babik::QuerySet::Clonable
Instance Attribute Details
#left_operand ⇒ Object (readonly)
Returns the value of attribute left_operand.
128 129 130 |
# File 'lib/babik/queryset.rb', line 128 def left_operand @left_operand end |
#right_operand ⇒ Object (readonly)
Returns the value of attribute right_operand.
128 129 130 |
# File 'lib/babik/queryset.rb', line 128 def right_operand @right_operand end |
Instance Method Details
#operation ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/babik/queryset.rb', line 136 def operation db_adapter = Babik::Database.config[:adapter] operation_name = self.class.to_s.split('::').last.upcase if %w[postgresql sqlite3].include?(db_adapter) || (%w[mysql2].include?(db_adapter) && operation_name == 'UNION') return operation_name end raise "#{db_adapter} does not support operation #{operation_name}" end |