Module: Dry::Protocol
- Defined in:
- lib/dry/behaviour.rb,
lib/dry/errors/not_protocol.rb,
lib/dry/errors/not_implemented.rb,
lib/dry/errors/duplicate_definition.rb,
lib/dry/errors/malformed_definition.rb
Overview
rubocop:enable Style/EmptyCaseCondition rubocop:enable Style/AsciiIdentifiers
Defined Under Namespace
Classes: DuplicateDefinition, MalformedDefinition, NotImplemented, NotProtocol
Class Method Summary collapse
-
.defimpl(protocol = nil, target: nil, delegate: [], map: {}, &λ) ⇒ Object
rubocop:disable Style/AsciiIdentifiers.
-
.implemented_for?(protocol, receiver) ⇒ Boolean
rubocop:disable Style/RaiseArgs.
- .included(base) ⇒ Object
Class Method Details
.defimpl(protocol = nil, target: nil, delegate: [], map: {}, &λ) ⇒ Object
rubocop:disable Style/AsciiIdentifiers
27 28 29 |
# File 'lib/dry/behaviour.rb', line 27 def defimpl(protocol = nil, target: nil, delegate: [], map: {}, &λ) Dry::BlackTie.defimpl(protocol, target: target, delegate: delegate, map: map, &λ) end |
.implemented_for?(protocol, receiver) ⇒ Boolean
rubocop:disable Style/RaiseArgs
33 34 35 36 |
# File 'lib/dry/behaviour.rb', line 33 def implemented_for?(protocol, receiver) raise ::Dry::Protocol::NotProtocol.new(protocol) unless protocol < ::Dry::Protocol !protocol.implementation_for(receiver).nil? end |