Class: Borneo::Mock::Service
- Inherits:
-
Object
- Object
- Borneo::Mock::Service
- Defined in:
- lib/borneo/mock/service.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(client, name, version) ⇒ Service
constructor
A new instance of Service.
- #method_missing(method_name) ⇒ Object
- #mock_response(components) ⇒ Object
- #to_return(result) ⇒ Object
Constructor Details
#initialize(client, name, version) ⇒ Service
Returns a new instance of Service.
5 6 7 8 9 10 11 |
# File 'lib/borneo/mock/service.rb', line 5 def initialize(client, name, version) @client = client @name = name @version = version @methods = {} @response_data = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/borneo/mock/service.rb', line 3 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/borneo/mock/service.rb', line 3 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/borneo/mock/service.rb', line 3 def version @version end |
Instance Method Details
#mock_response(components) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/borneo/mock/service.rb', line 17 def mock_response(components) if components.count == 0 @response_data else next_proxy = @methods[components[0]] unless next_proxy.nil? next_proxy.mock_response(components.drop(1)) else raise "Request not stubbed for #{components}" end end end |
#to_return(result) ⇒ Object
13 14 15 |
# File 'lib/borneo/mock/service.rb', line 13 def to_return(result) @response_data = result end |