Class: Validatable::ValidatesInclusionOf
Instance Attribute Summary
#attribute
Instance Method Summary
collapse
after_validate, after_validations, all_after_validations, all_defaults, default, defaults, #i18n_prefix, #initialize, option, #raise_error_if_key_is_dup, required_option, #run_after_validate, #should_validate?, #validate_this_time?
included, #requires
included, #must_understand
Instance Method Details
17
18
19
|
# File 'lib/validatable/validations/validates_inclusion_of.rb', line 17
def i18n
super || "#{i18n_prefix}.inclusion"
end
|
#message(instance) ⇒ Object
13
14
15
|
# File 'lib/validatable/validations/validates_inclusion_of.rb', line 13
def message(instance)
super || "is not in the list"
end
|
#valid?(instance) ⇒ Boolean
5
6
7
8
9
10
11
|
# File 'lib/validatable/validations/validates_inclusion_of.rb', line 5
def valid?(instance)
value = instance.send(attribute)
return true if allow_nil && value.nil?
return true if allow_blank && value.blank?
within.include?(value)
end
|