Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tfausak committed Oct 21, 2013
1 parent 133ab6b commit b0523fd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/active_interaction/errors.rb
Expand Up @@ -7,6 +7,8 @@ module ActiveInteraction

# A small extension to provide symbolic error messages to make introspecting
# and testing easier.
#
# @since 0.6.0
class Errors < ActiveModel::Errors
# A hash mapping attributes to arrays of symbolic messages.
#
Expand All @@ -15,17 +17,20 @@ class Errors < ActiveModel::Errors

# Adds a symbolic error message to an attribute.
#
# @param attribute [Symbol] The attribute to add an error to.
# @param symbol [Symbol] The symbolic error to add.
# @param message [String, Symbol, Proc]
# @param options [Hash]
#
# @example Adding a symbolic error.
# errors.add_sym(:attribute)
# errors.symbolic
# # => {:attribute=>[:invalid]}
# errors.messages
# # => {:attribute=>["is invalid"]}
# @param attribute [Symbol] The attribute to add an error to.
# @param symbol [Symbol] The symbolic error to add.
# @param message [String, Symbol, Proc]
# @param options [Hash]
#
# @return [Hash{Symbol => Array<Symbol>}]
#
# @see ActiveModel::Errors#add
def add_sym(attribute, symbol = :invalid, message = nil, options = {})
add(attribute, message || symbol, options)
Expand Down

0 comments on commit b0523fd

Please sign in to comment.