Object
Stores the argument lists for all methods for this class.
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
Calls an action and maps the params hash to the action parameters.
action | The action to call |
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.
Generated with the Darkfish Rdoc Generator 1.1.6.