Class: HealthInspector::Checklists::Base::CheckContext

Inherits:
Object
  • Object
show all
Includes:
HealthInspector::Check, HealthInspector::Color
Defined in:
lib/health_inspector/checklists/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HealthInspector::Check

#failure, #run_check

Methods included from HealthInspector::Color

#color

Constructor Details

#initialize(check, item, context) ⇒ CheckContext

Returns a new instance of CheckContext.



64
65
66
67
68
# File 'lib/health_inspector/checklists/base.rb', line 64

def initialize(check, item, context)
  @item = item
  @context = context
  @check = check
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



62
63
64
# File 'lib/health_inspector/checklists/base.rb', line 62

def context
  @context
end

#itemObject

Returns the value of attribute item.



62
63
64
# File 'lib/health_inspector/checklists/base.rb', line 62

def item
  @item
end

Instance Method Details

#callObject



70
71
72
# File 'lib/health_inspector/checklists/base.rb', line 70

def call
  instance_eval(&@check)
end

#diff(original, other) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/health_inspector/checklists/base.rb', line 74

def diff(original, other)
  (original.keys + other.keys).uniq.inject({}) do |memo, key|
    unless original[key] == other[key]
      if original[key].kind_of?(Hash) && other[key].kind_of?(Hash)
        memo[key] = diff(original[key], other[key])
      else
        memo[key] = {"server" => original[key],"local" => other[key]}
      end
    end
    memo
  end
end