Class: DiverDown::Trace::IgnoredMethodIds
- Inherits:
-
Object
- Object
- DiverDown::Trace::IgnoredMethodIds
- Defined in:
- lib/diver_down/trace/ignored_method_ids.rb
Constant Summary collapse
- VALID_VALUE =
%i[ single all ].freeze
Instance Method Summary collapse
-
#ignored(mod, is_class, method_id) ⇒ Symbol, false
VALID_VALUE.
-
#initialize(ignored_methods) ⇒ IgnoredMethodIds
constructor
A new instance of IgnoredMethodIds.
Constructor Details
#initialize(ignored_methods) ⇒ IgnoredMethodIds
Returns a new instance of IgnoredMethodIds.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/diver_down/trace/ignored_method_ids.rb', line 11 def initialize(ignored_methods) # Ignore all methods in the module # Hash{ Module => Symbol } @ignored_modules = {} # Ignore all methods in the class # Hash{ Module => Hash{ Symbol => Symbol } } @ignored_class_method_id = Hash.new { |h, k| h[k] = {} } # Ignore all methods in the instance # Hash{ Module => Hash{ Symbol => Symbol } } @ignored_instance_method_id = Hash.new { |h, k| h[k] = {} } ignored_methods.each do |ignored_method, value| raise ArgumentError, "Invalid value: #{value}. valid values are #{VALID_VALUE}" unless VALID_VALUE.include?(value) if ignored_method.include?('.') # instance method class_name, method_id = ignored_method.split('.') mod = DiverDown::Helper.constantize(class_name) @ignored_class_method_id[mod][method_id.to_sym] = value elsif ignored_method.include?('#') # class method class_name, method_id = ignored_method.split('#') mod = DiverDown::Helper.constantize(class_name) @ignored_instance_method_id[mod][method_id.to_sym] = value else # module mod = DiverDown::Helper.constantize(ignored_method) @ignored_modules[mod] = value end end end |
Instance Method Details
#ignored(mod, is_class, method_id) ⇒ Symbol, false
Returns VALID_VALUE.
49 50 51 |
# File 'lib/diver_down/trace/ignored_method_ids.rb', line 49 def ignored(mod, is_class, method_id) ignored_module(mod) || ignored_method(mod, is_class, method_id) end |