Class: SoftValidation::SoftValidation

Inherits:
Object
  • Object
show all
Defined in:
lib/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

#initializeSoftValidation

Returns a new instance of SoftValidation



210
211
212
# File 'lib/soft_validation.rb', line 210

def initialize
  @fixed = :fix_not_yet_run
end

Instance Attribute Details

#attributeSymbol

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



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#failure_messageString

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.



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#fixSymbol

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.



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#fix_triggerSymbol

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



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#fixedSymbol

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)



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#messageString

Returns Required. A short message describing the soft validation

Returns:

  • (String)

    Required. A short message describing the soft validation



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#success_messageString

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.



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/soft_validation.rb', line 207

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

  def initialize
    @fixed = :fix_not_yet_run
  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 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

#fixed?Boolean

Returns:

  • (Boolean)


214
215
216
217
# File 'lib/soft_validation.rb', line 214

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

#result_messageObject



219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/soft_validation.rb', line 219

def result_message
  case fixed
  when :fix_not_triggered
    'fix available, but not triggered'
  when :no_fix_available
    'fix not run, no 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