lib/dry/behaviour/black_tie.rb in dry-behaviour-0.9.0 vs lib/dry/behaviour/black_tie.rb in dry-behaviour-0.10.1

- old
+ new

@@ -4,10 +4,26 @@ # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/AbcSize # rubocop:disable Style/MethodName module BlackTie class << self + def proto_caller + caller.drop_while do |line| + line =~ %r[dry-behaviour/lib/dry/behaviour] + end.first + end + + def Logger + @logger ||= + if Kernel.const_defined?('::Rails') + Rails.logger + else + require 'logger' + Logger.new($stdout) + end + end + def protocols @protocols ||= Hash.new { |h, k| h[k] = h.dup.clear } end def implementations @@ -144,16 +160,10 @@ NORMALIZE_KEYS = lambda do |protocol| BlackTie.protocols[protocol].keys.reject { |k| k.to_s =~ /\A__.*__\z/ } end - def self.proto_caller - caller.drop_while do |line| - line =~ %r[dry-behaviour/lib/dry/behaviour] - end.first - end - IMPLICIT_DELEGATE_DEPRECATION = "\nЁЯЪия╕П DEPRECATED тЖТ %s\n" \ " ┬атой Implicit delegation to the target class will be removed in 1.0\n" \ " ┬атой due to the lack of the explicit implementation of %s#%s for %s\n" \ " ┬атой it will be delegated to the target class itself.\n" \ @@ -176,18 +186,9 @@ "\nЁЯЪия╕П DEPRECATED тЖТ %s\n" \ " ┬атой Wrong parameters declaration will be removed in 1.0\n" \ " ┬атой %s#%s was implemented for %s with unexpected parameters.\n" \ " ┬атой Consider implementing interfaces exactly as they were declared.\n" \ " ┬атой Expected: %s".freeze - - def self.Logger - @logger ||= if Kernel.const_defined?('::Rails') - Rails.logger - else - require 'logger' - Logger.new($stdout) - end - end private def normalize_map_delegates(delegate, map) [*delegate, *map].map do |e|