vendor/plugins/assert_request/lib/assert_request.rb
def assert_request #:yields: request
      safe_assertion do
        rules = RequestRules.new
        yield rules
        rules.validate(request)
      end
    end
# This is the granddaddy of the assertions for this plugin. Use this 
# method at the beginning of your action to declare the rules for requests
# that it receives. If a request doesn't match your declaration, then
# assert_request will raise a RequestError exception. By default, this
# gets turned into a 404 Not Found response in production mode.
#
# Here is a fairly complex assert_request declaration that illustrates some
# of its capabilities:
#
#   assert_request do |r|
#     r.method :post, :put
#     r.protocol :https
#     r.params.must_have :id
#     r.params.must_have :person do |person|
#       person.must_have :name
#       person.may_have :age, :height
#     end
#     r.params.must_have :fido do |fido|
#       fido.is_a Dog
#     end
#     r.params.may_have User do |user|
#       user.must_not_have :admin, :password
#     end
#   end
#
# It should be noted that assert_request will also raise a RequestError
# exception for unexpected params -- ones that aren't declared in your
# block. If this is too strict for your needs, or if you know some but not
# all of the params that you're going to encounter (such as in a 
# before_filter), then assert_params_must_have may be a good alternative.
#
# Here some pointers to within the documentation to learn about each part
# of the example above:
# 
# * RequestRules#method for the request method, such
#   as GET, POST, PUT, DELETE.
# * RequestRules#protocol for the protocol, such as HTTP or HTTPS
# * RequestRules#params for an overview of declaring parameters
#   * ParamRules#must_have for specifying elements that *must* appear in the
#     params hash.
#   * ParamRules#may_have for specifying elements that are permitted in the 
#     params hash, but are not required.
#   * ParamRules#is_a for a convenient shortcut for declaring params that
#     match an ActiveRecord model.
#   * ParamRules#must_not_have for excluding some attributes declared via
#     ParamRules#is_a.
# * RequestError for information about the exception that's raised when
#   a request doesn't match the declaration, and how that exception is 
#   handled.
# 
This is the granddaddy of the assertions for this plugin. Use this
method at the beginning of your action to declare the rules for requests
that it receives. If a request doesn't match your declaration, then
assert_request will raise a RequestError exception. By default, this
gets turned into a 404 Not Found response in production mode.

Here is a fairly complex assert_request declaration that illustrates some
of its capabilities.



It should be noted that assert_request will also raise a RequestError
exception for unexpected params -- ones that aren't declared in your
block. If this is too strict for your needs, or if you know some but not
all of the params that you're going to encounter (such as in a
before_filter), then assert_params_must_have may be a good alternative.

Here some pointers to within the documentation to learn about each part
of the example above.


This is the granddaddy of the assertions for this plugin . Use this method at the beginning of your action to declare the rules for requests that it receives . If a request doesn ' t match your declaration then assert_request will raise a RequestError exception . By default this gets turned into a 404 Not Found response in production mode . Here is a fairly complex assert_request declaration that illustrates some of its capabilities . It should be noted that assert_request will also raise a RequestError exception for unexpected params -- ones that aren ' t declared in your block . If this is too strict for your needs or if you know some but not all of the params that you ' re going to encounter ( such as in a before_filter ) then assert_params_must_have may be a good alternative . Here some pointers to within the documentation to learn about each part of the example above .
def assert_request 
      safe_assertion do
        rules = RequestRules.new
        yield rules
        rules.validate(request)
      end
    end
def assert_request safe_assertion do rules = RequestRules . new yield rules rules . validate ( request ) end end
This is the granddaddy of the assertions for this plugin.
This is the granddaddy of the assertions for this plugin .
#:yields: request