Sha256: 1cd5ac81a5b0ef0357eda259c759f14dd6439c1bc1909b7f5892021217a5e930

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

require "active_support/core_ext/module"
require "active_support/core_ext/object/blank"

require "directive"
require "grpc"

require_relative "proto_pharm/version"
require_relative "proto_pharm/configuration"

require_relative "proto_pharm/introspection"
require_relative "proto_pharm/stub_components/failure_response"

require_relative "proto_pharm/adapter"
require_relative "proto_pharm/grpc_stub_adapter"
require_relative "proto_pharm/grpc_stub_adapter/mock_stub"

require_relative "proto_pharm/metadata_serializers/base"
require_relative "proto_pharm/metadata_serializers/gruf"
require_relative "proto_pharm/request_stub"
require_relative "proto_pharm/action_stub"
require_relative "proto_pharm/matchers/request_including_matcher"
require_relative "proto_pharm/stub_registry"
require_relative "proto_pharm/api"

module ProtoPharm
  extend ProtoPharm::Api

  include Directive::ConfigDelegation
  delegates_to_configuration

  class << self
    delegate :enable!, :disable!, :enabled?, to: :adapter

    def reset!
      ProtoPharm.stub_registry.reset!
    end

    def stub_registry
      @stub_registry ||= ProtoPharm::StubRegistry.new
    end

    def adapter
      @adapter ||= Adapter.new
    end
  end

  # Hook into GRPC::ClientStub
  # https://github.com/grpc/grpc/blob/bec3b5ada2c5e5d782dff0b7b5018df646b65cb0/src/ruby/lib/grpc/generic/service.rb#L150-L186
  GRPC::ClientStub.prepend GrpcStubAdapter::MockStub
end

GrpcMock = ActiveSupport::Deprecation::DeprecatedConstantProxy.new("GrpcMock", "ProtoPharm")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proto_pharm-0.7.0 lib/proto_pharm.rb