Sha256: 3c1a51ba1d2beb3778df1a8ada3f29d568705b514b82f41262b20edb8503f62e

Contents?: true

Size: 1.45 KB

Versions: 16

Compression:

Stored size: 1.45 KB

Contents

require 'dry/behaviour/version'
require 'dry/errors'
require 'dry/behaviour/black_tie'
require 'dry/behaviour/cerberus'

module Dry
  # rubocop:disable Style/AsciiIdentifiers
  # rubocop:disable Style/EmptyCaseCondition
  DEFINE_METHOD = lambda do |target, this, *args, **params, &λ|
    case
    when !args.empty? && !params.empty? then this.send(target, *args, **params, &λ)
    when !args.empty? then this.send(target, *args, &λ)
    when !params.empty? then this.send(target, **params, &λ)
    else this.send(target, &λ)
    end
  end
  # rubocop:enable Style/EmptyCaseCondition
  # rubocop:enable Style/AsciiIdentifiers

  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

      # rubocop:disable Style/RaiseArgs
      def implemented_for?(protocol, receiver)
        raise ::Dry::Protocol::NotProtocol.new(protocol) unless protocol < ::Dry::Protocol
        !protocol.implementation_for(receiver).nil?
      end
      # rubocop:enable Style/RaiseArgs
    end
  end

  module Guards
    def self.included(base)
      ::Dry::Cerberus::POSTPONE_FIX_CLAUSES.(base)
      base.singleton_class.prepend(::Dry::Cerberus)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dry-behaviour-0.12.1 lib/dry/behaviour.rb
dry-behaviour-0.12.0 lib/dry/behaviour.rb
dry-behaviour-0.11.2 lib/dry/behaviour.rb
dry-behaviour-0.11.1 lib/dry/behaviour.rb
dry-behaviour-0.11.0 lib/dry/behaviour.rb
dry-behaviour-0.10.4 lib/dry/behaviour.rb
dry-behaviour-0.10.3 lib/dry/behaviour.rb
dry-behaviour-0.10.2 lib/dry/behaviour.rb
dry-behaviour-0.10.1 lib/dry/behaviour.rb
dry-behaviour-0.9.0 lib/dry/behaviour.rb
dry-behaviour-0.8.0 lib/dry/behaviour.rb
dry-behaviour-0.7.0 lib/dry/behaviour.rb
dry-behaviour-0.6.0 lib/dry/behaviour.rb
dry-behaviour-0.5.2 lib/dry/behaviour.rb
dry-behaviour-0.5.1 lib/dry/behaviour.rb
dry-behaviour-0.5.0 lib/dry/behaviour.rb