Use the `flat_map` method.
Thanks to @jeremy to teach me this one.
This commit is contained in:
parent
86062005a7
commit
d56b5dacb1
|
@ -188,9 +188,9 @@ module ActiveModel
|
||||||
# # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={:in=>0..99}>
|
# # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={:in=>0..99}>
|
||||||
# # ]
|
# # ]
|
||||||
def validators_on(*attributes)
|
def validators_on(*attributes)
|
||||||
attributes.map do |attribute|
|
attributes.flat_map do |attribute|
|
||||||
_validators[attribute.to_sym]
|
_validators[attribute.to_sym]
|
||||||
end.flatten
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns +true+ if +attribute+ is an attribute method, +false+ otherwise.
|
# Returns +true+ if +attribute+ is an attribute method, +false+ otherwise.
|
||||||
|
|
Loading…
Reference in New Issue