Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/resource_controller.rb

Class Method Summary collapse

Class Method Details

.actions(*opts) ⇒ Object

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


38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/resource_controller.rb', line 38

def self.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

.resource_controller(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/resource_controller.rb', line 23

def self.resource_controller(*args)
  include ResourceController::Controller
  include ResourceController::Urligence
  helper_method :smart_url

  if args.include?(:singleton)
    include ResourceController::Helpers::SingletonCustomizations
  end
end