Class: ActiveMocker::Mock::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



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

#hashObject



36
37
38
# File 'lib/active_mocker/mock/collection.rb', line 36

def hash
  @collection.hash
end

#to_aObject



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

def to_a
  @collection
end

#to_aryObject



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

def to_ary
  to_a
end