Class: DatabaseConsistency::DebugContext
- Inherits:
-
Object
- Object
- DatabaseConsistency::DebugContext
- Includes:
- Singleton
- Defined in:
- lib/database_consistency/debug_context.rb
Overview
The container that stores information for debugging purposes
Instance Method Summary collapse
-
#initialize ⇒ DebugContext
constructor
A new instance of DebugContext.
- #output(destination) ⇒ Object
- #with(context) ⇒ Object
Constructor Details
#initialize ⇒ DebugContext
Returns a new instance of DebugContext.
11 12 13 |
# File 'lib/database_consistency/debug_context.rb', line 11 def initialize clear! end |
Instance Method Details
#output(destination) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/database_consistency/debug_context.rb', line 29 def output(destination) store.each do |key, value| destination.puts("#{key}: #{value}") end clear! end |
#with(context) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/database_consistency/debug_context.rb', line 15 def with(context) context.each do |key, value| store[key] = value end result = yield context.each_key do |key| store.delete(key) end result end |