Class: SoftValidation::SoftValidation

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

Overview

A SoftValidation is identifies an individual issue with the instance it has been run against. It is generated by a soft_validation_method.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (SoftValidation) initialize(options = {})

Returns a new instance of SoftValidation



38
39
40
41
42
43
44
# File 'lib/soft_validation/soft_validation.rb', line 38

def initialize(options = {})
  @fixed = :fix_not_yet_run

  options.each do |k,v|
    send("#{k}=", v)
  end  
end

Instance Attribute Details

- (Symbol) attribute

Returns the attribute (column name), or :base to which the soft validation is tied

Returns:

  • (Symbol)

    the attribute (column name), or :base to which the soft validation is tied



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

- (String) failure_message

Returns Optional. Requires a fix method. A short message describing the message provided when the soft validation was NOT successfully fixed.

Returns:

  • (String)

    Optional. Requires a fix method. A short message describing the message provided when the soft validation was NOT successfully fixed.



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

- (Symbol) fix

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.

Returns:

  • (Symbol)

    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.



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

- (Symbol) fix_trigger

Returns Optional when :fix is provided. Must be one of :automatic or :requested. Defaults to :automatic

Returns:

  • (Symbol)

    Optional when :fix is provided. Must be one of :automatic or :requested. Defaults to :automatic



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

- (Symbol) fixed

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)

Returns:

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



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

- (String) message

Returns Required. A short message describing the soft validation

Returns:

  • (String)

    Required. A short message describing the soft validation



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

- (Object) resolution

Returns the value of attribute resolution



36
37
38
# File 'lib/soft_validation/soft_validation.rb', line 36

def resolution
  @resolution
end

- (String) success_message

Returns Optional. Requires a fix method. A short message describing the message provided when the soft validation was successfully fixed.

Returns:

  • (String)

    Optional. Requires a fix method. A short message describing the message provided when the soft validation was successfully fixed.



35
36
37
38
39
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
# File 'lib/soft_validation/soft_validation.rb', line 35

class SoftValidation
  attr_accessor :attribute, :message, :fix, :fix_trigger, :success_message, :failure_message, :fixed, :resolution

  def initialize(options = {})
    @fixed = :fix_not_yet_run

    options.each do |k,v|
      send("#{k}=", v)
    end  
  end

  def fixed?
    return true if fixed == :fixed
    false
  end

  def result_message
    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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
    when :fix_error 
      self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
    end
  end


end

Instance Method Details

- (Boolean) fixed?

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/soft_validation/soft_validation.rb', line 46

def fixed?
  return true if fixed == :fixed
  false
end

- (Object) result_message



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/soft_validation/soft_validation.rb', line 51

def result_message
  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.success_message.nil? ? "'#{message}' was fixed (no result message provided)" : self.success_message
  when :fix_error 
    self.failure_message.nil? ? "'#{message}' was NOT fixed (no result message provided)" : self.failure_message
  end
end