Class: ActiveMocker::Collection
- Inherits:
-
Object
- Object
- ActiveMocker::Collection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/active_mocker/mock/collection.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<<(*records) ⇒ Object
- #==(val) ⇒ Object
- #blank? ⇒ Boolean
- #each ⇒ Object
- #hash ⇒ Object
-
#initialize(collection = []) ⇒ Collection
constructor
A new instance of Collection.
- #to_a ⇒ Object
- #to_ary ⇒ Object
Constructor Details
#initialize(collection = []) ⇒ Collection
Returns a new instance of Collection.
11 12 13 |
# File 'lib/active_mocker/mock/collection.rb', line 11 def initialize(collection = []) @collection = collection end |
Instance Method Details
#<<(*records) ⇒ Object
15 16 17 |
# File 'lib/active_mocker/mock/collection.rb', line 15 def <<(*records) collection.concat(records.flatten) end |
#==(val) ⇒ Object
37 38 39 |
# File 'lib/active_mocker/mock/collection.rb', line 37 def ==(val) @collection == val end |
#blank? ⇒ Boolean
41 42 43 |
# File 'lib/active_mocker/mock/collection.rb', line 41 def blank? to_a.blank? end |
#each ⇒ Object
19 20 21 22 23 |
# File 'lib/active_mocker/mock/collection.rb', line 19 def each collection.each do |item| yield(item) end end |
#hash ⇒ Object
33 34 35 |
# File 'lib/active_mocker/mock/collection.rb', line 33 def hash @collection.hash end |
#to_a ⇒ Object
25 26 27 |
# File 'lib/active_mocker/mock/collection.rb', line 25 def to_a @collection end |
#to_ary ⇒ Object
29 30 31 |
# File 'lib/active_mocker/mock/collection.rb', line 29 def to_ary to_a end |