Module: Slack::Mixins::Speck::Check
- Defined in:
- lib/slack/mixins/speck/check.rb
Instance Method Summary collapse
-
#! ⇒ Object
This method can “invert” a ‘Check` object, such that it treats success of the original check block (a truthy return value) as failure (a false return value), and vice versa.
Instance Method Details
#! ⇒ Object
This method can “invert” a ‘Check` object, such that it treats success of the original check block (a truthy return value) as failure (a false return value), and vice versa.
This simply wraps the existing block in a new block that calls and inverts the return value.
13 14 15 16 17 18 19 20 21 |
# File 'lib/slack/mixins/speck/check.rb', line 13 def ! old_expectation, @expectation = @expectation, ->{ b = old_expectation.arity == 0 ? ->{old_expectation.call} : ->{old_expectation[@target.call]} @status = b.call ? false : true } return self end |