Class: ActiveRecord::Snapshot::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/snapshot/utils/logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step) ⇒ Logger

Returns a new instance of Logger.



8
9
10
# File 'lib/active_record/snapshot/utils/logger.rb', line 8

def initialize(step)
  @step = step
end

Class Method Details

.call(*args, &block) ⇒ Object



4
5
6
# File 'lib/active_record/snapshot/utils/logger.rb', line 4

def self.call(*args, &block)
  new(*args).call(&block)
end

Instance Method Details

#callObject



12
13
14
15
16
17
# File 'lib/active_record/snapshot/utils/logger.rb', line 12

def call
  start
  yield.tap do |success|
    success ? finish : failed
  end
end

#failedObject



27
28
29
# File 'lib/active_record/snapshot/utils/logger.rb', line 27

def failed
  $stderr.puts "== Failed: #{@step}"
end

#finishObject



23
24
25
# File 'lib/active_record/snapshot/utils/logger.rb', line 23

def finish
  puts "== Done"
end

#startObject



19
20
21
# File 'lib/active_record/snapshot/utils/logger.rb', line 19

def start
  puts "== Running: #{@step}"
end