class Ork::ResultSet
Public Class Methods
all(model, keys = nil)
click to toggle source
Find all documents in the Document’s bucket and return them.
@return Ork::ResultSet<Document> all the documents in the bucket
@Note: This operation can be incredibly expensive and should not
be used in production applications.
# File lib/ork/result_set.rb, line 22 def self.all(model, keys = nil) new(model, nil, nil).tap do |r| r.instance_variable_set(:@keys, keys || model.bucket.keys) end end
new(model, index, query, options={})
click to toggle source
# File lib/ork/result_set.rb, line 11 def initialize(model, index, query, options={}) @model, @index, @query, @options = model, index, query, options @bucket = @model.bucket end
Public Instance Methods
all()
click to toggle source
Get the array of objects
# File lib/ork/result_set.rb, line 48 def all return if self.keys.nil? @all ||= load_robjects @bucket.get_many(@keys) end
has_next_page?()
click to toggle source
Determine whether a SecondaryIndex fetch has a next page available
# File lib/ork/result_set.rb, line 66 def has_next_page? keys.respond_to?(:continuation) && !!keys.continuation end
inspect()
click to toggle source
Pretty print for the ResultSet
It uses keys when the objects are not present.
# File lib/ork/result_set.rb, line 31 def inspect string = "#<#{self.class}:#{@options} %s>" string % (@all || self.keys).inspect end
keys(&block)
click to toggle source
Get the array of matched keys
# File lib/ork/result_set.rb, line 39 def keys(&block) @keys ||= @bucket.client.backend do |b| b.get_index @bucket, @index.riak_name, @query, @options, &block end end
next_page()
click to toggle source
Get a new ResultSet
fetch for the next page
# File lib/ork/result_set.rb, line 55 def next_page raise Ork::NoNextPage.new 'There is no next page' unless has_next_page? self.class.new(@model, @index, @query, @options.merge(continuation: keys.continuation)) end
Private Instance Methods
load_robjects(robjects)
click to toggle source
# File lib/ork/result_set.rb, line 72 def load_robjects(robjects) robjects.map do |id, robject| @model.new.send(:__load_robject!, id, robject) end end