Class: DevelopWithPassion::Arrays::AddCriterion
- Defined in:
- lib/developwithpassion_arrays/add_criterion.rb
Instance Attribute Summary collapse
-
#criteria ⇒ Object
Returns the value of attribute criteria.
-
#failure_strategy ⇒ Object
Returns the value of attribute failure_strategy.
Instance Method Summary collapse
- #apply_to(value) ⇒ Object
-
#initialize(criteria, failure_strategy) ⇒ AddCriterion
constructor
A new instance of AddCriterion.
Constructor Details
#initialize(criteria, failure_strategy) ⇒ AddCriterion
Returns a new instance of AddCriterion.
6 7 8 9 |
# File 'lib/developwithpassion_arrays/add_criterion.rb', line 6 def initialize(criteria,failure_strategy) @criteria = criteria @failure_strategy = failure_strategy end |
Instance Attribute Details
#criteria ⇒ Object
Returns the value of attribute criteria.
4 5 6 |
# File 'lib/developwithpassion_arrays/add_criterion.rb', line 4 def criteria @criteria end |
#failure_strategy ⇒ Object
Returns the value of attribute failure_strategy.
4 5 6 |
# File 'lib/developwithpassion_arrays/add_criterion.rb', line 4 def failure_strategy @failure_strategy end |
Instance Method Details
#apply_to(value) ⇒ Object
11 12 13 14 15 |
# File 'lib/developwithpassion_arrays/add_criterion.rb', line 11 def apply_to(value) result = @criteria.is_satisfied_by(value) @failure_strategy.run(@criteria.name,value) unless result return result end |