Module: Dry::Protocol
- Defined in:
- lib/dry/behaviour.rb,
lib/dry/errors/not_protocol.rb,
lib/dry/errors/not_implemented.rb
Defined Under Namespace
Classes: NotImplemented, NotProtocol
Class Method Summary collapse
-
.defimpl(protocol = nil, target: nil, delegate: [], map: {}, &λ) ⇒ Object
rubocop:disable Style/AsciiIdentifiers.
-
.implemented_for?(protocol, receiver) ⇒ Boolean
rubocop:enable Style/AsciiIdentifiers.
- .included(base) ⇒ Object
Class Method Details
.defimpl(protocol = nil, target: nil, delegate: [], map: {}, &λ) ⇒ Object
rubocop:disable Style/AsciiIdentifiers
14 15 16 |
# File 'lib/dry/behaviour.rb', line 14 def defimpl(protocol = nil, target: nil, delegate: [], map: {}, & |
.implemented_for?(protocol, receiver) ⇒ Boolean
rubocop:enable Style/AsciiIdentifiers
19 20 21 22 |
# File 'lib/dry/behaviour.rb', line 19 def implemented_for?(protocol, receiver) raise NotProtocol.new(protocol) unless protocol < ::Dry::Protocol !protocol.implementation_for(receiver).nil? end |
.included(base) ⇒ Object
8 9 10 |
# File 'lib/dry/behaviour.rb', line 8 def self.included(base) base.singleton_class.prepend(Dry::BlackTie) end |