Class: Dolly::Collection
- Inherits:
-
Array
- Object
- Array
- Dolly::Collection
- Defined in:
- lib/dolly/collection.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #first_or_all(forced_first = false) ⇒ Object
-
#initialize(rows: [], options: {}) ⇒ Collection
constructor
A new instance of Collection.
- #single? ⇒ Boolean
Constructor Details
#initialize(rows: [], options: {}) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 11 12 |
# File 'lib/dolly/collection.rb', line 7 def initialize(rows: [], options: {}) @options = #TODO: We should raise an exception if one of the # requested documents is missing super rows[:rows].map(&collect_docs).compact end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/dolly/collection.rb', line 5 def @options end |
Instance Method Details
#first_or_all(forced_first = false) ⇒ Object
14 15 16 17 |
# File 'lib/dolly/collection.rb', line 14 def first_or_all(forced_first = false) return self if forced_first single? ? first : self end |
#single? ⇒ Boolean
19 20 21 |
# File 'lib/dolly/collection.rb', line 19 def single? size <= 1 end |