Module: Authorization::Identity::ModelExtensions::InstanceMethods
- Defined in:
- lib/publishare/identity.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *args) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/publishare/identity.rb', line 101 def method_missing( method_sym, *args ) method_name = method_sym.to_s if method_name =~ /^has_(\w+)\?$/ role_name = $1.singularize self.accepted_roles.find_all_by_name(role_name).any? { |role| role.users.any? } elsif method_name =~ /^has_(\w+)$/ role_name = $1.singularize users = self.accepted_roles.find_all_by_name(role_name).collect { |role| role.users } users.flatten.uniq if users else super end end |