1module PowerAssert 2 class << self 3 def configuration 4 @configuration ||= Configuration[false, false, true, false, false] 5 end 6 7 def configure 8 yield configuration 9 end 10 end 11 12 SUPPORT_ALIAS_METHOD = TracePoint.public_method_defined?(:callee_id) 13 private_constant :SUPPORT_ALIAS_METHOD 14 15 class Configuration < Struct.new(:lazy_inspection, :_trace_alias_method, :_redefinition, :_colorize_message, :_use_pp) 16 def _trace_alias_method=(bool) 17 super 18 if SUPPORT_ALIAS_METHOD 19 warn 'power_assert: _trace_alias_method option is obsolete. You no longer have to set it.' 20 end 21 end 22 23 def _colorize_message=(bool) 24 if bool 25 require 'pry' 26 end 27 super 28 end 29 30 def lazy_inspection=(bool) 31 unless bool 32 raise 'lazy_inspection option must be enabled when using pp' if _use_pp 33 end 34 super 35 end 36 37 def _use_pp=(bool) 38 if bool 39 raise 'lazy_inspection option must be enabled when using pp' unless lazy_inspection 40 require 'pp' 41 end 42 super 43 end 44 end 45 private_constant :Configuration 46end 47