Sha256: 46e318bef04622d1cfcacb85e02e25bf024c0ef604f78d503c057802838bba50
Contents?: true
Size: 820 Bytes
Versions: 21
Compression:
Stored size: 820 Bytes
Contents
module ResourceController module ClassMethods # 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 def actions(*opts) config = {} config.merge!(opts.pop) if opts.last.is_a?(Hash) all_actions = (singleton? ? ResourceController::SINGLETON_ACTIONS : ResourceController::ACTIONS) - [:new_action] + [:new] actions_to_remove = [] actions_to_remove += all_actions - opts unless opts.first == :all actions_to_remove += [*config[:except]] if config[:except] actions_to_remove.uniq! actions_to_remove.each { |action| undef_method(action) if method_defined?(action) } end end end
Version data entries
21 entries across 21 versions & 12 rubygems