Class: ActiveMocker::Mock::Collection
- Inherits:
-
Object
- Object
- ActiveMocker::Mock::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(&block) ⇒ Object
- #hash ⇒ Object
-
#initialize(collection = []) ⇒ Collection
constructor
A new instance of Collection.
- #to_a ⇒ Object
- #to_ary ⇒ Object
Constructor Details
#initialize(collection = []) ⇒ Collection
14 15 16 |
# File 'lib/active_mocker/mock/collection.rb', line 14 def initialize(collection=[]) @collection = [*collection] end |
Instance Method Details
#<<(*records) ⇒ Object
18 19 20 |
# File 'lib/active_mocker/mock/collection.rb', line 18 def <<(*records) collection.concat(records.flatten) end |
#==(val) ⇒ Object
40 41 42 |
# File 'lib/active_mocker/mock/collection.rb', line 40 def ==(val) @collection == val end |
#blank? ⇒ Boolean
44 45 46 |
# File 'lib/active_mocker/mock/collection.rb', line 44 def blank? to_a.blank? end |
#each(&block) ⇒ Object
22 23 24 25 26 |
# File 'lib/active_mocker/mock/collection.rb', line 22 def each(&block) collection.each do |item| yield(item) end end |
#hash ⇒ Object
36 37 38 |
# File 'lib/active_mocker/mock/collection.rb', line 36 def hash @collection.hash end |
#to_a ⇒ Object
28 29 30 |
# File 'lib/active_mocker/mock/collection.rb', line 28 def to_a @collection end |
#to_ary ⇒ Object
32 33 34 |
# File 'lib/active_mocker/mock/collection.rb', line 32 def to_ary to_a end |