Class: JCR::EvalConditions

Inherits:
Object
  • Object
show all
Defined in:
lib/jcr/evaluate_rules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapping, callbacks, trace = false) ⇒ EvalConditions

Returns a new instance of EvalConditions.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/jcr/evaluate_rules.rb', line 58

def initialize mapping, callbacks, trace = false
  @failures = []
  @mapping = mapping
  @trace = trace
  @trace_stack = []
  if callbacks
    @callbacks = callbacks
  else
    @callbacks = {}
  end
end

Instance Attribute Details

#callbacksObject

Returns the value of attribute callbacks.



57
58
59
# File 'lib/jcr/evaluate_rules.rb', line 57

def callbacks
  @callbacks
end

#failuresObject

Returns the value of attribute failures.



57
58
59
# File 'lib/jcr/evaluate_rules.rb', line 57

def failures
  @failures
end

#mappingObject

Returns the value of attribute mapping.



57
58
59
# File 'lib/jcr/evaluate_rules.rb', line 57

def mapping
  @mapping
end

#traceObject

Returns the value of attribute trace.



57
58
59
# File 'lib/jcr/evaluate_rules.rb', line 57

def trace
  @trace
end

#trace_stackObject

Returns the value of attribute trace_stack.



57
58
59
# File 'lib/jcr/evaluate_rules.rb', line 57

def trace_stack
  @trace_stack
end

Instance Method Details

#report_failure(failure) ⇒ Object



70
71
72
73
74
# File 'lib/jcr/evaluate_rules.rb', line 70

def report_failure failure
  stack_level = trace_stack.length - 1
  @failures[ stack_level ] = Array.new unless @failures[ stack_level ]
  @failures[ stack_level ] << failure
end

#report_successObject



76
77
78
79
# File 'lib/jcr/evaluate_rules.rb', line 76

def report_success
  stack_level = trace_stack.length - 1
  @failures.slice!( stack_level..-1 )
end