Class: Suture::Surgeon::Observer

Inherits:
Object
  • Object
show all
Defined in:
lib/suture/surgeon/observer.rb

Instance Method Summary collapse

Instance Method Details

#operate(plan) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/suture/surgeon/observer.rb', line 6

def operate(plan)
  dictaphone = Suture::Adapter::Dictaphone.new(plan)
  begin
    Suture::Util::Scalpel.new.cut(plan, :old).tap do |result|
      dictaphone.record(result)
    end
  rescue StandardError => error
    if plan.expected_error_types.any? {|e| error.kind_of?(e) }
      dictaphone.record_error(error)
    end
    raise error
  end
end