Created
February 1, 2012 08:48
-
-
Save mokevnin/1716007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AccessHelper | |
include AuthHelper | |
def check_access(values = {}) | |
acl.check! self.class.to_s, self.action_name, current_roles, values | |
end | |
def current_roles | |
@current_roles ||= current_user.roles_hash.keys | |
end | |
def acl | |
YaAcl::Acl.instance | |
end | |
def can?(route_method, action = nil, options = {}) | |
url_options = send "hash_for_#{route_method}_path" | |
resource = "#{url_options[:controller].to_s.camelize}Controller" | |
privilege = action || url_options[:action] | |
acl.allow? resource, privilege, current_roles, options | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment