Class: Reaction::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/reaction/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @action = action
  @options = options
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



3
4
5
# File 'lib/reaction/validator.rb', line 3

def action
  @action
end

#errorObject

Returns the value of attribute error.



6
7
8
# File 'lib/reaction/validator.rb', line 6

def error
  @error
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/reaction/validator.rb', line 4

def options
  @options
end

#successfulObject

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

Returns:

  • (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