Sha256: dc95b50e6ed8de5a662e3c53ac53073c84cd567dec708f95a1fb5b6531530d17

Contents?: true

Size: 1.31 KB

Versions: 89

Compression:

Stored size: 1.31 KB

Contents

module Sunspot
  module Query
    class StartRecord #:nodoc:
      attr_reader :start_record, :maximum_record

      def initialize(start_record = nil, maximum_record = nil)
        self.start_record, self.maximum_record = start_record, maximum_record
      end

      def to_params
        { :start => start, :rows => rows }
      end

      def start_record=(start_record)
        @start_record = start_record.to_i - 1 if start_record
      end

      def maximum_record=(maximum_record)
        @maximum_record = maximum_record.to_i if maximum_record
      end

      private

      def start
        @start_record
      end

      def rows
        @maximum_record
      end
    end

    class CommonQuery
      def start_record(start, maximum)
        if @start_record
          @start_record.start = start
          @start_record.maximum = maximum
        else
          @components << @start_record = StartRecord.new(start, maximum)
        end
      end
    end
  end

  module DSL #:nodoc:
    class Query < FieldQuery
      def start_record(options = {})
        start = options.delete(:start)
        maximum = options.delete(:maximum)
        raise ArgumentError, "unknown argument #{options.keys.first.inspect} passed to paginate" unless options.empty?
        @query.start_record(start, maximum)
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 3 rubygems

Version Path
enju_biblio-0.1.0.pre33 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre32 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc1 lib/plugins/ext/sunspot/start_record.rb
enju_flower-0.1.0.pre4 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre31 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.beta3 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.pre3 lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre30 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre29 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_flower-0.1.0.pre3 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre28 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre27 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre26 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_flower-0.1.0.pre2 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre25 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre24 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre23 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre22 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre21 spec/dummy/lib/plugins/ext/sunspot/start_record.rb
enju_biblio-0.1.0.pre20 spec/dummy/lib/plugins/ext/sunspot/start_record.rb