Sha256: 70512e154987c870bc7db95561054e8e9961f9ab7f7f5f3526393cba661011e6

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 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
    include 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(*args)
      callback.call(*args)
    end

    def arity
      callback.arity
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stub_requests-0.1.4 lib/stub_requests/callback.rb