Class: Reaction::Validator
- Inherits:
-
Object
- Object
- Reaction::Validator
- Defined in:
- lib/reaction/validator.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#error ⇒ Object
Returns the value of attribute error.
-
#options ⇒ Object
Returns the value of attribute options.
-
#successful ⇒ Object
Returns the value of attribute successful.
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #failure(error) ⇒ Object
-
#initialize(action, options = {}) ⇒ Validator
constructor
A new instance of Validator.
- #process(value) ⇒ Object
Constructor Details
#initialize(action, options = {}) ⇒ Validator
Returns a new instance of Validator.
10 11 12 13 |
# File 'lib/reaction/validator.rb', line 10 def initialize(action, = {}) @action = action @options = end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
3 4 5 |
# File 'lib/reaction/validator.rb', line 3 def action @action end |
#error ⇒ Object
Returns the value of attribute error.
6 7 8 |
# File 'lib/reaction/validator.rb', line 6 def error @error end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/reaction/validator.rb', line 4 def @options end |
#successful ⇒ Object
Returns the value of attribute successful.
7 8 9 |
# File 'lib/reaction/validator.rb', line 7 def successful @successful end |
Instance Method Details
#failed? ⇒ Boolean
28 29 30 |
# File 'lib/reaction/validator.rb', line 28 def failed? @successful == false end |
#failure(error) ⇒ Object
23 24 25 26 |
# File 'lib/reaction/validator.rb', line 23 def failure(error) @error = error @successful = false end |
#process(value) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/reaction/validator.rb', line 15 def process(value) # Assume successful unless a failure for validators @successful = true validate(value) !!@successful end |