Class: SoftValidation::SoftValidation
- Inherits:
-
Object
- Object
- SoftValidation::SoftValidation
- Defined in:
- lib/soft_validation/soft_validation.rb
Overview
A SoftValidation identifies an individual issue with the instance it has been run against. It is generated by a soft_validation_method.
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
Optional.
-
#fix_trigger ⇒ Symbol
Optional when :fix is provided.
-
#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.
-
#resolution ⇒ Object
Returns the value of attribute resolution.
-
#success_message ⇒ String
Optional.
Instance Method Summary collapse
- #fixed? ⇒ Boolean
-
#initialize(options = {}) ⇒ SoftValidation
constructor
A new instance of SoftValidation.
- #result_message ⇒ String
Constructor Details
#initialize(options = {}) ⇒ SoftValidation
Returns a new instance of SoftValidation.
44 45 46 47 48 49 50 |
# File 'lib/soft_validation/soft_validation.rb', line 44 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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end 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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end end |
#fix ⇒ Symbol
Returns Optional. Identifies a method that fixes the soft validation in question. I.e. the method when run should eliminate subsequent identical soft validation warnings from being generated. Fix methods should return true or false.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end end |
#fix_trigger ⇒ Symbol
Returns Optional when :fix is provided. Must be one of :automatic or :requested. Defaults to :automatic.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end 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).
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end end |
#message ⇒ String
Returns Required. A short message describing the soft validation.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end end |
#resolution ⇒ Object
Returns the value of attribute resolution.
41 42 43 |
# File 'lib/soft_validation/soft_validation.rb', line 41 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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/soft_validation/soft_validation.rb', line 40 class SoftValidation attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution # @param [Hash] args def initialize( = {}) @fixed = :fix_not_yet_run .each do |k,v| send("#{k}=", v) end end # @return [Boolean] def fixed? return true if fixed == :fixed false end # @return [String] def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end end |
Instance Method Details
#fixed? ⇒ Boolean
53 54 55 56 |
# File 'lib/soft_validation/soft_validation.rb', line 53 def fixed? return true if fixed == :fixed false end |
#result_message ⇒ String
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/soft_validation/soft_validation.rb', line 59 def case fixed when :fix_not_triggered 'fix available, but not triggered' when :no_fix_available 'fix not run, no automatic fix available' when :fix_not_yet_run 'fix not yet run' when :fixed self..nil? ? "'#{}' was fixed (no result message provided)" : self. when :fix_error self..nil? ? "'#{}' was NOT fixed (no result message provided)" : self. end end |