Module: Authorizable::ControllerMethods::ClassMethods

Defined in:
lib/authorizable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_authorizable(*args) ⇒ Object

This mixin method will :

  • set the action skipping the logging part

  • define the method checking the permission depending of the action

  • set this method as a before_filter



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/authorizable.rb', line 19

def acts_as_authorizable(*args)
				options = args.extract_options!
				skip_before_filter :is_logged?, :only => options[:skip_logging_actions]
				before_filter :permission_checking
				define_method :permission_checking do
					if options[:actions_permissions_links][params[:action]]
obj = params[:controller].split('/')[1].classify.constantize
@current_object ||= ['new', 'create','validate'].include?(params[:action]) ? obj.new : obj.find(params[:id])
#no_permission_redirection unless @current_user && @current_object.send("accepts_#{hash[params[:action]]}_for?".to_sym, @current_user)
no_permission_redirection unless @current_user && @current_object.has_permission_for?(options[:actions_permissions_links][params[:action]], @current_user, current_container ? current_container.class.to_s.underscore : 'workspace')
					else
# it is permissive
					end
				end
				include Authorizable::ControllerMethods::InstanceMethods
end