Class: StubRequests::Callback
- Includes:
- StubRequests::Concerns::Property
- Defined in:
- lib/stub_requests/callback.rb
Overview
Class Callback contains information about a subscription
Instance Attribute Summary collapse
-
#callback ⇒ Proc
A proc to callback on notify.
-
#endpoint_id ⇒ Symbol
The id of an endpoint.
-
#service_id ⇒ Symbol
The id of a service.
-
#verb ⇒ Symbol
The HTTP verb/method.
Instance Method Summary collapse
- #arity ⇒ Object
- #call(request_stub) ⇒ Object
-
#initialize(service_id, endpoint_id, verb, callback) ⇒ Callback
constructor
Initialize a new Callback.
Methods included from StubRequests::Concerns::Property
Methods included from StubRequests::Concerns::ArgumentValidation
Constructor Details
#initialize(service_id, endpoint_id, verb, callback) ⇒ Callback
Initialize a new Callback
45 46 47 48 49 50 |
# File 'lib/stub_requests/callback.rb', line 45 def initialize(service_id, endpoint_id, verb, callback) self.service_id = service_id self.endpoint_id = endpoint_id self.verb = verb self.callback = callback end |
Instance Attribute Details
#callback ⇒ Proc
Returns a proc to callback on notify
35 |
# File 'lib/stub_requests/callback.rb', line 35 property :callback, type: Proc |
#endpoint_id ⇒ Symbol
Returns the id of an endpoint
27 |
# File 'lib/stub_requests/callback.rb', line 27 property :endpoint_id, type: Symbol |
Instance Method Details
#arity ⇒ Object
63 64 65 |
# File 'lib/stub_requests/callback.rb', line 63 def arity callback.arity end |
#call(request_stub) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/stub_requests/callback.rb', line 52 def call(request_stub) case arity when 0 callback.call when 1 callback.call(request_stub) else raise InvalidCallback, "The callback for a callback can either take 0 or 1 arguments (was #{arity})" end end |