Class: SoftValidation::SoftValidationMethod
- Inherits:
-
Object
- Object
- SoftValidation::SoftValidationMethod
- Defined in:
- lib/soft_validation/soft_validation_method.rb
Overview
A metadata structure for each soft validation
Instance Attribute Summary collapse
-
#description ⇒ Object
@return[String, nil] human description of this soft validation.
-
#has_fix ⇒ Object
@return by default everything is fixable nil = fixable true = fixable (default value, not necessary option) false = not fixable manual assertion of whether the method has a fix !! This needs better reconcilition ultimately, as it is not coupled with sv_method inspection !!.
-
#klass ⇒ Object
@param the (base) klass that has method.
-
#method ⇒ Object
@param the soft validation method.
-
#name ⇒ Object
@return[String, nil] human name/title of this soft validation.
- #resolution ⇒ Array
-
#set ⇒ Object
@return[Symbol, nil] assign this soft validation method to a set.
Instance Method Summary collapse
-
#described? ⇒ Boolean
@return a name and description provided.
-
#fixable? ⇒ Boolean
Alias for has_fix.
-
#initialize(options) ⇒ SoftValidationMethod
constructor
A new instance of SoftValidationMethod.
-
#resolutions? ⇒ Boolean
@return whether there resolutions.
-
#to_s ⇒ Object
@return a human readable string describing the general point of this soft validation method.
Constructor Details
#initialize(options) ⇒ SoftValidationMethod
Returns a new instance of SoftValidationMethod.
40 41 42 43 44 45 46 47 |
# File 'lib/soft_validation/soft_validation_method.rb', line 40 def initialize() raise(SoftValidationError, 'missing method and klass') if [:method].nil? || [:klass].nil? .each do |k,v| send("#{k}=", v) end @has_fix = true if @has_fix.nil? end |
Instance Attribute Details
#description ⇒ Object
@return[String, nil] human description of this soft validation
20 21 22 |
# File 'lib/soft_validation/soft_validation_method.rb', line 20 def description @description end |
#has_fix ⇒ Object
by default everything is fixable
nil = fixable
true = fixable (default value, not necessary option)
false = not fixable
manual assertion of whether the method has a fix
!! This needs better reconcilition ultimately, as it is not coupled with sv_method inspection !!
37 38 39 |
# File 'lib/soft_validation/soft_validation_method.rb', line 37 def has_fix @has_fix end |
#klass ⇒ Object
@param the (base) klass that has method
12 13 14 |
# File 'lib/soft_validation/soft_validation_method.rb', line 12 def klass @klass end |
#method ⇒ Object
@param the soft validation method
8 9 10 |
# File 'lib/soft_validation/soft_validation_method.rb', line 8 def method @method end |
#name ⇒ Object
@return[String, nil]
human name/title of this soft validation
16 17 18 |
# File 'lib/soft_validation/soft_validation_method.rb', line 16 def name @name end |
#resolution ⇒ Array
24 25 26 |
# File 'lib/soft_validation/soft_validation_method.rb', line 24 def resolution @resolution end |
#set ⇒ Object
@return[Symbol, nil]
assign this soft validation method to a set
28 29 30 |
# File 'lib/soft_validation/soft_validation_method.rb', line 28 def set @set end |
Instance Method Details
#described? ⇒ Boolean
65 66 67 |
# File 'lib/soft_validation/soft_validation_method.rb', line 65 def described? !name.blank? && !description.blank? end |
#fixable? ⇒ Boolean
Returns alias for has_fix.
77 78 79 |
# File 'lib/soft_validation/soft_validation_method.rb', line 77 def fixable? has_fix end |
#resolutions? ⇒ Boolean
whether there resolutions
71 72 73 |
# File 'lib/soft_validation/soft_validation_method.rb', line 71 def resolutions? resolution.size > 0 end |
#to_s ⇒ Object
a human readable string describing the general point of this soft validation method
83 84 85 |
# File 'lib/soft_validation/soft_validation_method.rb', line 83 def to_s [(name.blank? ? "#{method} (temporary name)" : name), (description.blank? ? '(no description provided)' : description)].join(': ') end |