Module: Authorization::Identity::ModelExtensions::InstanceMethods
- Defined in:
- lib/authorization/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
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/authorization/publishare/identity.rb', line 96
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 }
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
|
Instance Method Details
#respond_to?(method_sym) ⇒ Boolean
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/authorization/publishare/identity.rb', line 110
def respond_to? method_sym
method_name = method_sym.to_s
if method_name =~ /^has_(\w+)\?$/
true
elsif method_name =~ /^has_(\w+)$/
true
else
super
end
end
|