Created
March 29, 2009 00:28
-
-
Save zhhz/87244 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
#Role.rb | |
... | |
def authorizable_class | |
return nil if authorizable_type.nil? | |
klass = begin | |
authorizable_type.split("::").inject(Object){|x, y| x.const_get(y)} | |
rescue NameError => e | |
msg = "Class not found: `#{authorizable_type}'" | |
Merb.logger.warn!(msg) | |
nil | |
end | |
end | |
def callable_actions | |
klass = authorizable_class | |
return [] if klass.nil? || !klass.respond_to?(:callable_actions)# make sure is a controller | |
actions = klass.callable_actions.keys - klass.superclass.callable_actions.keys | |
actions.sort | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment