Permalink
Browse files

[merb-auth-core] Improved active_model compatibility

  • Loading branch information...
1 parent 5d1a78d commit 3ca624371852c73644c62dcc02f5ef5344105298 @snusnu snusnu committed Sep 24, 2009
Showing with 11 additions and 0 deletions.
  1. +11 −0 merb-auth-core/lib/merb-auth-core/errors.rb
View
11 merb-auth-core/lib/merb-auth-core/errors.rb
@@ -33,6 +33,17 @@ def full_messages
end
end
+ # Return validation errors for a particular field name or an empty array
+ #
+ # This method is a necessary requirement for active_model compatibility.
+ #
+ # @param [Symbol] field_name the name of the field you want an error for
+ # @return [Array<Array<String>>]
+ # array of validation errors or empty array, if there are no errors on given field
+ def [](field_name)
+ errors[field_name] ||= []
+ end
+
# Return authentication errors for a particular field_name.
#
# @param <Symbol> field_name the name of the field you want an error for

0 comments on commit 3ca6243

Please sign in to comment.