Class: SoftValidation::SoftValidation
- Inherits:
-
Object
- Object
- SoftValidation::SoftValidation
- Defined in:
- lib/soft_validation/soft_validation.rb
Overview
A SoftValidation is a instance of an actual issue. It strictly a message passing structure.
Instance Attribute Summary collapse
-
#attribute ⇒ Symbol
The attribute (column name), or :base to which the soft validation is tied.
-
#failure_message ⇒ String
Optional.
-
#fix ⇒ Symbol?
readonly
Optional.
-
#fixed ⇒ Symbol
Stores a state with one of :fixed (fixes run and SoftValidation was fixed), :fix_error (fixes run and SoftValidation fix failed), :fix_not_triggered (fixes run, and SoftValidation was not triggered because of scope) :fix_not_yet_run (there is a fix method available, but it hasn’t been run) :no_fix_available (no fix method was provided).
-
#message ⇒ String
Required.
-
#method_instance ⇒ Symbol?
writeonly
The method name of the fix that can resolve this soft validation.
-
#resolution ⇒ String?
readonly
Optional.
-
#success_message ⇒ String
Optional.
Instance Method Summary collapse
- #description ⇒ Object
- #fixable? ⇒ Boolean
- #fixed? ⇒ Boolean
-
#initialize(options = {}) ⇒ SoftValidation
constructor
A new instance of SoftValidation.
- #result_message ⇒ String
- #soft_validation_method ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SoftValidation
Returns a new instance of SoftValidation.
50 51 52 53 54 55 |
# File 'lib/soft_validation/soft_validation.rb', line 50 def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end |
Instance Attribute Details
#attribute ⇒ Symbol
Returns the attribute (column name), or :base to which the soft validation is tied.
14 15 16 |
# File 'lib/soft_validation/soft_validation.rb', line 14 def attribute @attribute end |
#failure_message ⇒ String
Returns Optional. Requires a fix method. A short message describing the message provided when the soft validation was NOT successfully fixed.
29 30 31 |
# File 'lib/soft_validation/soft_validation.rb', line 29 def @failure_message end |
#fix ⇒ Symbol? (readonly)
Returns Optional. The method name of the fix that can resolve this soft validation.
37 38 39 |
# File 'lib/soft_validation/soft_validation.rb', line 37 def fix @fix end |
#fixed ⇒ Symbol
Returns Stores a state with one of :fixed (fixes run and SoftValidation was fixed), :fix_error (fixes run and SoftValidation fix failed), :fix_not_triggered (fixes run, and SoftValidation was not triggered because of scope) :fix_not_yet_run (there is a fix method available, but it hasn’t been run) :no_fix_available (no fix method was provided).
47 48 49 |
# File 'lib/soft_validation/soft_validation.rb', line 47 def fixed @fixed end |
#message ⇒ String
Returns Required. A short message describing the soft validation.
19 20 21 |
# File 'lib/soft_validation/soft_validation.rb', line 19 def @message end |
#method_instance=(value) ⇒ Symbol? (writeonly)
Returns The method name of the fix that can resolve this soft validation.
9 10 11 |
# File 'lib/soft_validation/soft_validation.rb', line 9 def method_instance=(value) @method_instance = value end |
#resolution ⇒ String? (readonly)
Returns Optional. A named route that points to where the issue can be resolved.
33 34 35 |
# File 'lib/soft_validation/soft_validation.rb', line 33 def resolution @resolution end |
#success_message ⇒ String
Returns Optional. Requires a fix method. A short message describing the message provided when the soft validation was successfully fixed.
24 25 26 |
# File 'lib/soft_validation/soft_validation.rb', line 24 def @success_message end |
Instance Method Details
#description ⇒ Object
57 58 59 |
# File 'lib/soft_validation/soft_validation.rb', line 57 def description @method_instance.description end |
#fixable? ⇒ Boolean
74 75 76 77 |
# File 'lib/soft_validation/soft_validation.rb', line 74 def fixable? return true if !method_instance.fix.nil? false end |
#fixed? ⇒ Boolean
80 81 82 83 |
# File 'lib/soft_validation/soft_validation.rb', line 80 def fixed? return true if fixed == :fixed false end |
#result_message ⇒ String
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/soft_validation/soft_validation.rb', line 86 def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'no fix available' when :fix_not_yet_run 'fix not yet run' when :fixed .nil? ? "'#{}' was fixed (no result message provided)" : when :fix_error .nil? ? "'#{}' was NOT fixed (no result message provided)" : end end |
#soft_validation_method ⇒ Object
69 70 71 |
# File 'lib/soft_validation/soft_validation.rb', line 69 def soft_validation_method @method_instance.method end |