Class: GSGraph::Searchable::Result
- Inherits:
-
Collection
- Object
- Array
- Collection
- GSGraph::Searchable::Result
- Defined in:
- lib/gs_graph/searchable/result.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#options ⇒ Object
Returns the value of attribute options.
-
#query ⇒ Object
Returns the value of attribute query.
Attributes inherited from Collection
#total_count, #unread_count, #updated_time
Instance Method Summary collapse
-
#initialize(query, klass, options = {}) ⇒ Result
constructor
A new instance of Result.
- #next(_options_ = {}) ⇒ Object
- #previous(_options_ = {}) ⇒ Object
Constructor Details
#initialize(query, klass, options = {}) ⇒ Result
Returns a new instance of Result.
6 7 8 9 10 11 12 |
# File 'lib/gs_graph/searchable/result.rb', line 6 def initialize(query, klass, = {}) @klass = klass @query = query @options = @collection = .delete(:collection) || Collection.new replace @collection end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
4 5 6 |
# File 'lib/gs_graph/searchable/result.rb', line 4 def collection @collection end |
#klass ⇒ Object
Returns the value of attribute klass.
4 5 6 |
# File 'lib/gs_graph/searchable/result.rb', line 4 def klass @klass end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/gs_graph/searchable/result.rb', line 4 def @options end |
#query ⇒ Object
Returns the value of attribute query.
4 5 6 |
# File 'lib/gs_graph/searchable/result.rb', line 4 def query @query end |
Instance Method Details
#next(_options_ = {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/gs_graph/searchable/result.rb', line 14 def next( = {}) if self.collection.next.present? self.klass.search(self.query, self..merge().merge(self.collection.next)) else self.class.new(self.query, self.klass) end end |
#previous(_options_ = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/gs_graph/searchable/result.rb', line 22 def previous( = {}) if self.collection.previous.present? self.klass.search(self.query, self..merge().merge(self.collection.previous)) else self.class.new(self.query, self.klass) end end |