Class: ActiveSet::Paginating::EnumerableStrategy

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

Instance Method Summary collapse

Constructor Details

#initialize(set, operation_instructions) ⇒ EnumerableStrategy

Returns a new instance of EnumerableStrategy.



6
7
8
9
# File 'lib/active_set/paginating/enumerable_strategy.rb', line 6

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

Instance Method Details

#executeObject



11
12
13
14
15
16
# File 'lib/active_set/paginating/enumerable_strategy.rb', line 11

def execute
  return [] if @set.count <= @operation_instructions[:size] &&
               @operation_instructions[:page] > 1

  @set[page_start..page_end] || []
end