Class: ActiveSet::Filtering::EnumerableStrategy

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

Instance Method Summary collapse

Constructor Details

#initialize(set, attribute_instruction) ⇒ EnumerableStrategy

Returns a new instance of EnumerableStrategy.



17
18
19
20
21
# File 'lib/active_set/filtering/enumerable_strategy.rb', line 17

def initialize(set, attribute_instruction)
  @set = set
  @attribute_instruction = attribute_instruction
  @set_instruction = EnumerableSetInstruction.new(attribute_instruction, set)
end

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_set/filtering/enumerable_strategy.rb', line 23

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

  if execute_filter_operation?
    set = filter_operation
  elsif execute_intersect_operation?
    begin
      set = intersect_operation
    rescue TypeError # thrown if intersecting with a non-Array
      return false
    end
  else
    return false
  end

  set
end