Class: Pipeable::Steps::Check
- Defined in:
- lib/pipeable/steps/check.rb
Overview
Checks if proof is true and answers success (passthrough) or failure (with optional argument).
Instance Method Summary collapse
- #call(result) ⇒ Object
-
#initialize(proof, message) ⇒ Check
constructor
A new instance of Check.
Methods included from Composable
Constructor Details
#initialize(proof, message) ⇒ Check
Returns a new instance of Check.
9 10 11 12 13 |
# File 'lib/pipeable/steps/check.rb', line 9 def initialize proof, super() @proof = proof @message = end |
Instance Method Details
#call(result) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/pipeable/steps/check.rb', line 15 def call result result.bind do |object| answer = question object answer == true || answer.is_a?(Success) ? result : Failure(object) end end |