Class: ActiveSet::Filtering::ActiveRecordStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_set/filtering/active_record_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(set, attribute_instruction) ⇒ ActiveRecordStrategy



6
7
8
9
# File 'lib/active_set/filtering/active_record_strategy.rb', line 6

def initialize(set, attribute_instruction)
  @set = set
  @attribute_instruction = attribute_instruction
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_set/filtering/active_record_strategy.rb', line 11

def execute
  return false unless @set.respond_to? :to_sql

  if execute_where_operation?
    statement = where_operation
  elsif execute_merge_operation?
    begin
      statement = merge_operation
    rescue ArgumentError # thrown if merging a non-ActiveRecord::Relation
      return false
    end
  else
    return false
  end

  statement
end