Class: DevelopWithPassion::Arrays::AddCriterion

Inherits:
Object
  • Object
show all
Defined in:
lib/developwithpassion_arrays/add_criterion.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#criteriaObject

Returns the value of attribute criteria.



4
5
6
# File 'lib/developwithpassion_arrays/add_criterion.rb', line 4

def criteria
  @criteria
end

#failure_strategyObject

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