Sha256: f87f6543264801a21e4b28f92d29fec3d3b0e276b161c65333a4053dcbe33b8b

Contents?: true

Size: 908 Bytes

Versions: 6

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

require_relative './processor_base'
require_relative './processor_paginate/enumerable_adapter'
require_relative './processor_paginate/active_record_adapter'

class ActiveSet
  class Processor::Paginate < Processor::Base
    def process
      adapters.each do |adapter|
        result = adapter.new(@set, @instructions).process
        break(result) if result
      end
    end

    private

    def validate_instructions(instructions)
      {
        page:   (instructions[:page] ||
                 instructions['page'] ||
                 1).to_i,
        size:   (instructions[:size] ||
                 instructions['size'] ||
                 25).to_i,
        outset: (instructions[:outset] ||
                 instructions['outset'] ||
                 0).to_i
      }
    end

    register_adapter(EnumerableAdapter)
    register_adapter(ActiveRecordAdapter)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activeset-0.6.5 lib/active_set/processor_paginate.rb
activeset-0.6.4 lib/active_set/processor_paginate.rb
activeset-0.6.3 lib/active_set/processor_paginate.rb
activeset-0.6.2 lib/active_set/processor_paginate.rb
activeset-0.6.1 lib/active_set/processor_paginate.rb
activeset-0.6.0 lib/active_set/processor_paginate.rb