class Unravel::Registry

Attributes

achievements[R]
contexts[R]
errors[R]
fixes[R]
symptoms[R]

Public Class Methods

new() click to toggle source
# File lib/unravel.rb, line 40
def initialize
  @fixes = {}
  @symptoms = {}
  @achievements = {}
  @contexts = {}
  @errors = {}
end

Public Instance Methods

add_achievement(name, &block) click to toggle source
# File lib/unravel.rb, line 71
def add_achievement(name, &block)
  @achievements[name] = block
end
add_error_contexts(name, contexts) click to toggle source
# File lib/unravel.rb, line 81
def add_error_contexts(name, contexts)
  @contexts[name] ||= contexts
end
add_fix(name, block) click to toggle source
# File lib/unravel.rb, line 58
def add_fix(name, block)
  fail HumanInterventionNeeded, "fix for root cause #{name} already exists" if @fixes.key?(name)
  @fixes[name] = block
end
add_symptom(symptom, root_cause) click to toggle source
# File lib/unravel.rb, line 67
def add_symptom(symptom, root_cause)
  @symptoms[symptom] = root_cause
end
error_contexts_for_achievement(name) click to toggle source
# File lib/unravel.rb, line 85
def error_contexts_for_achievement(name)
  @contexts[name].tap do |context|
    fail HumanInterventionNeeded, "No error handlers for achievement: #{name}" unless context
  end
end
fixable_error(name) click to toggle source
# File lib/unravel.rb, line 91
def fixable_error(name)
  @errors[name]
end
get_achievement(name) click to toggle source
# File lib/unravel.rb, line 75
def get_achievement(name)
  @achievements[name].tap do |achievement|
    fail HumanInterventionNeeded, "No such achievement: #{name.inspect}" unless achievement
  end
end
get_fix_for(cause) click to toggle source
# File lib/unravel.rb, line 52
def get_fix_for(cause)
  achievement_or_block = @fixes[cause]
  fail HumanInterventionNeeded, "No fix for: #{cause}" unless achievement_or_block
  achievement_or_block
end
get_root_cause(symptom) click to toggle source
# File lib/unravel.rb, line 63
def get_root_cause(symptom)
  @symptoms[symptom]
end
has_fix_for?(cause) click to toggle source
# File lib/unravel.rb, line 48
def has_fix_for?(cause)
  @fixes.key?(cause)
end