Class: ActiveMocker::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/active_mocker/mock/collection.rb

Direct Known Subclasses

Relation

Instance Method Summary collapse

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

Returns:

  • (Boolean)


41
42
43
# File 'lib/active_mocker/mock/collection.rb', line 41

def blank?
  to_a.blank?
end

#eachObject



19
20
21
22
23
# File 'lib/active_mocker/mock/collection.rb', line 19

def each
  collection.each do |item|
    yield(item)
  end
end

#hashObject



33
34
35
# File 'lib/active_mocker/mock/collection.rb', line 33

def hash
  @collection.hash
end

#to_aObject



25
26
27
# File 'lib/active_mocker/mock/collection.rb', line 25

def to_a
  @collection
end

#to_aryObject



29
30
31
# File 'lib/active_mocker/mock/collection.rb', line 29

def to_ary
  to_a
end