Class: JCR::EvalConditions
- Inherits:
-
Object
- Object
- JCR::EvalConditions
- Defined in:
- lib/jcr/evaluate_rules.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#mapping ⇒ Object
Returns the value of attribute mapping.
-
#trace ⇒ Object
Returns the value of attribute trace.
-
#trace_stack ⇒ Object
Returns the value of attribute trace_stack.
Instance Method Summary collapse
-
#initialize(mapping, callbacks, trace = false) ⇒ EvalConditions
constructor
A new instance of EvalConditions.
- #report_failure(failure) ⇒ Object
- #report_success ⇒ Object
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
#callbacks ⇒ Object
Returns the value of attribute callbacks.
57 58 59 |
# File 'lib/jcr/evaluate_rules.rb', line 57 def callbacks @callbacks end |
#failures ⇒ Object
Returns the value of attribute failures.
57 58 59 |
# File 'lib/jcr/evaluate_rules.rb', line 57 def failures @failures end |
#mapping ⇒ Object
Returns the value of attribute mapping.
57 58 59 |
# File 'lib/jcr/evaluate_rules.rb', line 57 def mapping @mapping end |
#trace ⇒ Object
Returns the value of attribute trace.
57 58 59 |
# File 'lib/jcr/evaluate_rules.rb', line 57 def trace @trace end |
#trace_stack ⇒ Object
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_success ⇒ Object
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 |