Class: ActiveSet::Paginating::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/active_set/paginating/operation.rb

Instance Method Summary collapse

Constructor Details

#initialize(set, instructions_hash) ⇒ Operation

Returns a new instance of Operation.



9
10
11
12
# File 'lib/active_set/paginating/operation.rb', line 9

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

Instance Method Details

#executeObject



14
15
16
17
18
19
# File 'lib/active_set/paginating/operation.rb', line 14

def execute
  [ActiveRecordStrategy, EnumerableStrategy].each do |strategy|
    maybe_set_or_false = strategy.new(@set, operation_instructions).execute
    break(maybe_set_or_false) if maybe_set_or_false
  end
end

#operation_instructionsObject



21
22
23
24
25
26
27
# File 'lib/active_set/paginating/operation.rb', line 21

def operation_instructions
  @instructions_hash.symbolize_keys.tap do |h|
    h[:page] = page_operation_instruction(h[:page])
    h[:size] = size_operation_instruction(h[:size])
    h[:count] = count_operation_instruction(@set)
  end
end