Class: ActiveSet::Filtering::Enumerable::Strategy

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

Instance Method Summary collapse

Constructor Details

#initialize(set, attribute_instruction) ⇒ Strategy

Returns a new instance of Strategy.



20
21
22
23
24
# File 'lib/active_set/filtering/enumerable/strategy.rb', line 20

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

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/active_set/filtering/enumerable/strategy.rb', line 26

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