Parent

Merb::AbstractController

Attributes

action_argument_list[RW]

Public Class Methods

inherited(klass) click to toggle source

Stores the argument lists for all methods for this class.

Parameters

klass

The controller that is being inherited from Merb::AbstractController.

    # File lib/merb-action-args/abstract_controller.rb, line 12
12:     def inherited(klass)
13:       klass.action_argument_list = Hash.new do |h,k|
14:         args = klass.instance_method(k).get_args
15:         arguments = args[0]
16:         defaults = []
17:         arguments.each {|a| defaults << a[0] if a.size == 2} if arguments
18:         h[k] = [arguments || [], defaults]
19:       end
20:       old_inherited(klass)
21:     end
Also aliased as: old_inherited
old_inherited(klass) click to toggle source
Alias for: inherited

Public Instance Methods

_call_action(action) click to toggle source

Calls an action and maps the params hash to the action parameters.

Parameters

action

The action to call

Raises

BadRequest

The params hash doesn’t have a required parameter.

    # File lib/merb-action-args/abstract_controller.rb, line 31
31:   def _call_action(action)
32:     arguments, defaults = self.class.action_argument_list[action]
33:     
34:     args = arguments.map do |arg, default|
35:       p = params.key?(arg.to_sym)
36:       unless p || (defaults && defaults.include?(arg))
37:         missing = arguments.reject {|arg| params.key?(arg[0].to_sym || arg[1])}
38:         raise BadRequest, "Your parameters (#{params.inspect}) were missing #{missing.join(", ")}"
39:       end
40:       p ? params[arg.to_sym] : default
41:     end
42:     __send__(action, *args)
43:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.