Sha256: 4de70e05b410454fc74de28c9ab489e33eb79ebf70f02801f7a12abac33f7c2f

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

#
# Abstraction over WebMock to reduce duplication
#
# @author Mikael Henriksson <mikael@zoolutions.se>
# @since 0.1.0
#
module StubRequests
  #
  # Module Observable handles observing webmock requests
  #
  # @author Mikael Henriksson <mikael@zoolutions.se>
  # @since 0.1.3
  #
  module Observable
    #
    # Subscribe to a service endpoint call
    # @see Observable::Registry#subscribe
    #
    #
    # @param [Symbol] service_id the id of a service
    # @param [Symbol] endpoint_id the id of an endpoint
    # @param [Symbol] verb the HTTP verb to subscribe to
    # @param [Proc] callback the callback to use for when.a request was made
    #
    # @return [Subscription]
    #
    # :reek:LongParameterList
    def self.subscribe_to(service_id, endpoint_id, verb, callback)
      Registry.instance.subscribe(service_id, endpoint_id, verb, callback)
    end

    #
    # Unsubscribe from a service endpoint call
    # @see Observable::Registry#unsubscribe
    #
    #
    # @param [Symbol] service_id the id of a service
    # @param [Symbol] endpoint_id the id of an endpoint
    # @param [Symbol] verb the HTTP verb to subscribe to
    #
    # @return [Subscription]
    #
    def self.unsubscribe_from(service_id, endpoint_id, verb)
      Registry.instance.unsubscribe(service_id, endpoint_id, verb)
    end

    #
    # Notifies subscribers that a request was made
    # @see Observable::Registry#notify_subscribers
    #
    #
    # @param [Metrics::Request] request the stubbed request
    #
    # @return [Request]
    #
    def self.notify_subscribers(request)
      Registry.instance.notify_subscribers(request)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stub_requests-0.1.3 lib/stub_requests/observable.rb