Class: WebMock::Resources::ResourceInstanceStorage

Inherits:
Array
  • Object
show all
Defined in:
lib/webmock-resources/resource_instance_storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource_type) ⇒ ResourceInstanceStorage

Returns a new instance of ResourceInstanceStorage.



4
5
6
# File 'lib/webmock-resources/resource_instance_storage.rb', line 4

def initialize resource_type
  @resource_type = resource_type
end

Instance Method Details

#<<(instance) ⇒ Object



14
15
16
17
18
# File 'lib/webmock-resources/resource_instance_storage.rb', line 14

def << instance
  super instance

  Stubber.instance.stub_resource @resource_type, instance.id
end

#find(id) ⇒ Object



8
9
10
11
12
# File 'lib/webmock-resources/resource_instance_storage.rb', line 8

def find id
  super do |resource|
    resource.id == id
  end
end