Sha256: 8ca30dac7652c76614c309f69d93bdcbf1778a7e2f66fcfa2035ba5567be1b44
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
# frozen_string_literal: true # # Abstraction over WebMock to reduce duplication # # @author Mikael Henriksson <mikael@zoolutions.se> # @since 0.1.0 # module StubRequests # # Class Callback contains information about a subscription # # @author Mikael Henriksson <mikael@zoolutions.se> # @since 0.1.3 # class Callback # includes "Concerns::Property" # @!parse include Concerns::Property include Concerns::Property # # @!attribute [rw] service_id # @return [Symbol] the id of a service property :service_id, type: Symbol # # @!attribute [rw] endpoint_id # @return [Symbol] the id of an endpoint property :endpoint_id, type: Symbol # # @!attribute [rw] verb # @return [Symbol] the HTTP verb/method property :verb, type: Symbol, default: :any # # @!attribute [rw] callback # @return [Proc] a proc to callback on notify property :callback, type: Proc # # Initialize a new Callback # # @param [Symbol] service_id the id of a service # @param [Symbol] endpoint_id the id of an endpoint # @param [Symbol] verb the HTTP verb/method # @param [Proc] callback a proc to callback on notify # 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 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 def arity callback.arity end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stub_requests-0.1.11 | lib/stub_requests/callback.rb |
stub_requests-0.1.10 | lib/stub_requests/callback.rb |