Exception: DoNotWant::NotSafe

Inherits:
Exception
  • Object
show all
Defined in:
lib/do_not_want.rb

Instance Method Summary collapse

Constructor Details

#initialize(called_object, called_method, reason) ⇒ NotSafe

Returns a new instance of NotSafe.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/do_not_want.rb', line 29

def initialize(called_object, called_method, reason)
  class_name = called_object.class.name
  method_name = called_method.to_s

  method_description = if called_object.is_a?(Class)
                         "#{called_object.name}.#{method_name}"
                       else
                         "#{class_name}##{method_name}"
                       end

  super "#{method_description} isn't safe because %s" % [
    reason
  ]
end