Skip to content

Commit

Permalink
Added documentation for RequiresParameters module so people know what…
Browse files Browse the repository at this point in the history
… its for
  • Loading branch information
Joshua Delsman committed Apr 16, 2009
1 parent 0833f2b commit 44d2454
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/requires_parameters.rb
@@ -1,5 +1,22 @@
module Whm #:nodoc:
module RequiresParameters #:nodoc:
# Allows for parameter requirements for methods
module RequiresParameters
# Check the included hash for the included parameters.
#
# ==== Example
#
# <tt>:username</tt> and <tt>:password</tt> are required parameters
#
# requires!(options, :username, :password)
#
# So, if <tt>User.new</tt> doesn't pass these parameters, an
# ArgumentError exception is thrown.
#
# >> User.new
# ArgumentError: Missing required parameter: username
#
# >> User.new(:username => "john")
# ArgumentError: Missing required parameter: password
def requires!(hash, *params)
params.each do |param|
if param.is_a?(Array)
Expand Down

0 comments on commit 44d2454

Please sign in to comment.