Sha256: 2f3a9c9c31778dfc45a1e36787b5da942215564a17d92d3565f347186b2d28c2

Contents?: true

Size: 743 Bytes

Versions: 4

Compression:

Stored size: 743 Bytes

Contents

require 'dry/behaviour/version'
require 'dry/errors/not_implemented'
require 'dry/errors/not_protocol'
require 'dry/behaviour/black_tie'

module Dry
  module Protocol
    def self.included(base)
      base.singleton_class.prepend(Dry::BlackTie)
    end

    class << self
      # rubocop:disable Style/AsciiIdentifiers
      def defimpl(protocol = nil, target: nil, delegate: [], map: {}, &λ)
        Dry::BlackTie.defimpl(protocol, target: target, delegate: delegate, map: map, &λ)
      end
      # rubocop:enable Style/AsciiIdentifiers

      def implemented_for?(protocol, receiver)
        raise NotProtocol.new(protocol) unless protocol < ::Dry::Protocol
        !protocol.implementation_for(receiver).nil?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-behaviour-0.4.2 lib/dry/behaviour.rb
dry-behaviour-0.4.1 lib/dry/behaviour.rb
dry-behaviour-0.4.0 lib/dry/behaviour.rb
dry-behaviour-0.3.1 lib/dry/behaviour.rb