Sha256: 442913341ff0ff37a2777e0bfe74d20a48856416635f521432a62b2394dd1dd5

Contents?: true

Size: 673 Bytes

Versions: 3

Compression:

Stored size: 673 Bytes

Contents

require 'active_support/core_ext/hash/indifferent_access'

module Waistband
  class FreeQuery

    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
    end

    def prepare(hash)
      @hash = hash.with_indifferent_access
    end

    private

      def to_hash
        raise "No query has been prepared yet!" unless @hash

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

        @hash
      end

    # /private

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
waistband-0.4.2 lib/waistband/free_query.rb
waistband-0.4.1 lib/waistband/free_query.rb
waistband-0.4.0 lib/waistband/free_query.rb