Class: Bail::ConditionTester
- Inherits:
-
Object
- Object
- Bail::ConditionTester
- Includes:
- Helpers
- Defined in:
- lib/bail/condition_tester.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type) ⇒ ConditionTester
constructor
A new instance of ConditionTester.
- #run(condition_parser, objects) ⇒ Object
Methods included from Helpers
#condition_hash_to_lambda, #questionable
Constructor Details
#initialize(type) ⇒ ConditionTester
Returns a new instance of ConditionTester.
9 10 11 12 13 |
# File 'lib/bail/condition_tester.rb', line 9 def initialize(type) # can be methods from Enumerable basically # i.e. :any?, :all? @type = questionable(type) end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/bail/condition_tester.rb', line 7 def type @type end |
Instance Method Details
#run(condition_parser, objects) ⇒ Object
15 16 17 18 19 |
# File 'lib/bail/condition_tester.rb', line 15 def run(condition_parser, objects) if objects.send(type) {|object| condition_parser.test(object)} raise Bail::ConditionError.new('A Bail condition has failed.') end end |