class Babik::QuerySet::SetOperation

Each one of the set operations that can be executed in SQL

Attributes

left_operand[R]
right_operand[R]

Public Class Methods

new(model, left_operand, right_operand) click to toggle source
Calls superclass method Babik::QuerySet::AbstractBase::new
# 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

Public Instance Methods

operation() click to toggle source
# 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