| Module | ResourceController::ClassMethods |
| In: |
../lib/resource_controller/class_methods.rb
|
Use this method in your controller to specify which actions you‘d like it to respond to.
class PostsController < ResourceController::Base
actions :all, :except => :create
end
# File ../lib/resource_controller/class_methods.rb, line 9
9: def actions(*opts)
10: config = {}
11: config.merge!(opts.pop) if opts.last.is_a?(Hash)
12:
13: all_actions = (singleton? ? ResourceController::SINGLETON_ACTIONS : ResourceController::ACTIONS) - [:new_action] + [:new]
14:
15: actions_to_remove = []
16: actions_to_remove += all_actions - opts unless opts.first == :all
17: actions_to_remove += [*config[:except]] if config[:except]
18: actions_to_remove.uniq!
19:
20: actions_to_remove.each { |action| undef_method(action)}
21: end