Class: ActiveModel::Validations::HashValuesValidator
- Inherits:
-
ArrayValidator
- Object
- EachValidator
- ArrayValidator
- ActiveModel::Validations::HashValuesValidator
show all
- Defined in:
- lib/can_has_validations/validators/hash_values_validator.rb
Defined Under Namespace
Modules: HashValidatorKey
Instance Attribute Summary
#validators
Instance Method Summary
collapse
Constructor Details
24
25
26
27
28
|
# File 'lib/can_has_validations/validators/hash_values_validator.rb', line 24
def initialize(options)
record_class = options[:class]
super
record_class.include HashValidatorKey
end
|
Instance Method Details
#validate_each(record, attribute, hash) ⇒ Object
30
31
32
|
# File 'lib/can_has_validations/validators/hash_values_validator.rb', line 30
def validate_each(record, attribute, hash)
super(record, attribute, Array(Hash(hash)))
end
|
#validate_one(validator, record, attribute, key_and_value) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/can_has_validations/validators/hash_values_validator.rb', line 34
def validate_one(validator, record, attribute, key_and_value)
key, value = key_and_value
record.hash_validator_key = key
super(validator, record, attribute, value)
ensure
record.hash_validator_key = nil
end
|