Class: FullMetalBody::InputValidation

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, InputKeyUtils
Defined in:
lib/full_metal_body/input_validation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, whitelist) ⇒ InputValidation

Returns a new instance of InputValidation.

Parameters:

  • key (Array<String, Symbol>)
  • value (Object)
  • whitelist (Hash)


22
23
24
25
26
27
28
29
30
31
# File 'lib/full_metal_body/input_validation.rb', line 22

def initialize(key, value, whitelist)
  @key = key
  @value = value
  set_key_type(whitelist)
  if value_validate
    class_eval %(
    validates :value, #{value_validate} # validates :value, input_string: true
  ), __FILE__, __LINE__ - 2
  end
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



15
16
17
# File 'lib/full_metal_body/input_validation.rb', line 15

def key
  @key
end

#key_typeObject

Returns the value of attribute key_type.



15
16
17
# File 'lib/full_metal_body/input_validation.rb', line 15

def key_type
  @key_type
end

#valueObject

Returns the value of attribute value.



15
16
17
# File 'lib/full_metal_body/input_validation.rb', line 15

def value
  @value
end