Sha256: e2aff6663ffb89982f9afaba991790aea7473ed63ab5f81fa3763c89dc8e0e87

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

require 'active_support/core_ext/hash/indifferent_access'

module Waistband
  class Query

    include ::Waistband::QueryHelpers

    attr_accessor :page, :page_size

    def initialize(index, options = {})
      @index      = index
      @page       = (options[:page] || 1).to_i
      @page_size  = (options[:page_size] || 20).to_i
      prepare
    end

    def prepare(hash = {})
      @hash = hash.with_indifferent_access
      self
    end

    private

      def to_hash
        @hash[:from] = from       unless @hash[:from]
        @hash[:size] = @page_size unless @hash[:size]

        @hash
      end

    # /private

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
waistband-0.7.3 lib/waistband/query.rb
waistband-0.7.1 lib/waistband/query.rb