Class: SoftValidation::SoftValidationMethod

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

Overview

A metadata structure for each soft validation

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (SoftValidationMethod) initialize(options)

Returns a new instance of SoftValidationMethod



30
31
32
33
34
35
36
# File 'lib/soft_validation/soft_validation_method.rb', line 30

def initialize(options)
  raise(SoftValidationError, 'missing method and klass') if options[:method].nil? || options[:klass].nil?

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

Instance Attribute Details

- (Object) description

@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

- (Object) klass

@param the (base) klass that has method



12
13
14
# File 'lib/soft_validation/soft_validation_method.rb', line 12

def klass
  @klass
end

- (Object) method

@param the soft validation method



8
9
10
# File 'lib/soft_validation/soft_validation_method.rb', line 8

def method
  @method
end

- (Object) name

@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

- (Object) resolution

@return[Array, nil] of symbols



24
25
26
# File 'lib/soft_validation/soft_validation_method.rb', line 24

def resolution
  @resolution
end

- (Object) set

@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

- (Boolean) described?

@return

a name and description provided

Returns:

  • (Boolean)


51
52
53
# File 'lib/soft_validation/soft_validation_method.rb', line 51

def described?
  !name.blank? && !description.blank?
end

- (Boolean) resolutions?

@return

whether there resolutions

Returns:

  • (Boolean)


57
58
59
# File 'lib/soft_validation/soft_validation_method.rb', line 57

def resolutions?
  resolution.size > 0
end

- (Object) to_s

@return

a human readable string describing the general point of this soft validation method


63
64
65
# File 'lib/soft_validation/soft_validation_method.rb', line 63

def to_s
  [(name.blank? ? "#{method} (temporary name)" : name), (description.blank? ? '(no description provided)' : description)].join(': ')
end