Class: Suture::ChoosesSurgeon

Inherits:
Object
  • Object
show all
Includes:
Adapter::Log
Defined in:
lib/suture/create/chooses_surgeon.rb

Instance Method Summary collapse

Methods included from Adapter::Log

#log_debug, #log_error, #log_info, #log_warn, logger, reset!

Instance Method Details

#choose(plan) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/suture/create/chooses_surgeon.rb', line 11

def choose(plan)
  return Surgeon::NoOp.new if plan.disable
  if plan.record_calls
    if plan.new
      log_warn <<-MSG.gsub(/^ {12}/,'')
        Seam #{plan.name.inspect} has a :new code path defined, but because
        it is set to :record_calls, we will invoke the :old code path
        instead. If this is not what you intend, set :record_calls to false.
      MSG
    end
    Surgeon::Observer.new
  elsif plan.call_both
    Surgeon::Auditor.new
  elsif plan.fallback_on_error
    Surgeon::Remediator.new
  else
    Surgeon::NoOp.new
  end
end