Module: PermissiveController::ClassMethods

Defined in:
lib/authorized/permissive_controller.rb

Instance Method Summary collapse

Instance Method Details

#permissive(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/authorized/permissive_controller.rb', line 6

def permissive(*args)
	options = args.extract_options!
	resource = options[:resource] || ActiveSupport::ModelName.new(
		self.model_name.split('::').last.gsub(/Controller$/,'').singularize)

#	remove NameSpace or create the may*required permission

	before_filter "may_create_#{resource.plural}_required",
		:only => [:new,:create]
	before_filter "may_read_#{resource.plural}_required",
		:only => [:show,:index]
	before_filter "may_update_#{resource.plural}_required",
		:only => [:edit,:update]
	before_filter "may_destroy_#{resource.plural}_required",
		:only => :destroy

end