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_leaf-1.1.4 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.3 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.2 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.1 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc22 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc21 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc20 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc19 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc18 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc17 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc16 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc15 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc14 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc13 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc12 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc11 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc10 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc9 lib/plugins/ext/sunspot/start_record.rb
enju_leaf-1.1.0.rc8 lib/plugins/ext/sunspot/start_record.rb