Module: Testable::Ready
- Includes:
- Situation
- Defined in:
- lib/testable/ready.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#ready ⇒ Object
Returns the value of attribute ready.
-
#ready_error ⇒ Object
Returns the value of attribute ready_error.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#ready ⇒ Object
Returns the value of attribute ready.
27 28 29 |
# File 'lib/testable/ready.rb', line 27 def ready @ready end |
#ready_error ⇒ Object
Returns the value of attribute ready_error.
27 28 29 |
# File 'lib/testable/ready.rb', line 27 def ready_error @ready_error end |
Class Method Details
.included(caller) ⇒ Object
29 30 31 |
# File 'lib/testable/ready.rb', line 29 def self.included(caller) caller.extend(ClassMethods) end |
Instance Method Details
#ready? ⇒ Boolean
45 46 47 48 49 |
# File 'lib/testable/ready.rb', line 45 def ready? self.ready_error = nil return true if ready ready_validations_pass? end |
#ready_validations_pass? ⇒ Boolean
51 52 53 54 55 56 57 |
# File 'lib/testable/ready.rb', line 51 def ready_validations_pass? self.class.ready_validations.all? do |validation| passed, = instance_eval(&validation) self.ready_error = if && !passed passed end end |
#when_ready(&_block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/testable/ready.rb', line 33 def when_ready(&_block) already_marked_ready = ready no_ready_check_possible unless block_given? self.ready = ready? not_ready_validation(ready_error || 'NO REASON PROVIDED') unless ready yield self ensure self.ready = already_marked_ready end |