Method: ActiveSet::Sorting::Operation#execute

Defined in:
lib/active_set/sorting/operation.rb

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_set/sorting/operation.rb', line 15

def execute
  attribute_instructions = flatten_keys_of(@instructions_hash)
                           .map { |k, v| AttributeInstruction.new(k, v) }

  activerecord_strategy = ActiveRecordStrategy.new(@set, attribute_instructions)
  if activerecord_strategy.executable_instructions == attribute_instructions
    activerecord_sorted_set = activerecord_strategy.execute
  end

  return activerecord_sorted_set if attribute_instructions.all?(&:processed?)

  EnumerableStrategy.new(@set, attribute_instructions).execute
end