Use the `flat_map` method.

Thanks to @jeremy to teach me this one.
This commit is contained in:
Rafael Mendonça França 2012-10-03 00:17:10 -03:00
parent 86062005a7
commit d56b5dacb1
1 changed files with 2 additions and 2 deletions

View File

@ -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.