summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2013-05-29 15:03:22 +0200
committerrautenberg <rautenberg@in-silico.ch>2013-05-29 15:03:22 +0200
commitef122484598a8979de915344cdeff475cff752c5 (patch)
tree6eb1fdde3212b26b028388a465d63ee6429dcc0c
parent0df97a547ad623cff5d714076addbaa3cc73c53b (diff)
authorization.rb merge free_uri? and authorize_exceptions?
-rw-r--r--lib/authorization.rb37
1 files changed, 14 insertions, 23 deletions
diff --git a/lib/authorization.rb b/lib/authorization.rb
index 4d49b40..469c16c 100644
--- a/lib/authorization.rb
+++ b/lib/authorization.rb
@@ -337,33 +337,24 @@ module OpenTox
end
private
- # @return [Boolean] checks if uri-method pair is included in :free_uri
- def self.free_uri?(uri, request_method)
- if $aa[:free_uris]
- $aa[:free_uris].each do |request_methods,uris|
- if request_methods and uris and request_methods.include?(request_method.to_sym)
- uris.each do |u|
- return true if u.match uri
- end
- end
- end
- end
- return false
- end
-
- # @return [Boolean] checks if uri-method pair is included in :authorize_exceptions
- def self.authorize_exception?(uri, request_method)
- if $aa[:authorize_exceptions]
- $aa[:authorize_exceptions].each do |request_methods,uris|
- if request_methods and uris and request_methods.include?(request_method.to_sym)
- uris.each do |u|
- return true if u.match uri
+ # extend class methods
+ class << self
+ # methods: free_uri and authorize_exception
+ # @return [Boolean] checks if uri-method pair is included in $aa[:free_uri] or $aa[:authorize_exception]
+ [:free_uri, :authorize_exception].each do |method|
+ define_method "#{method}?".to_sym do |uri, request_method|
+ if $aa["#{method}s".to_sym]
+ $aa["#{method}s".to_sym].each do |request_methods, uris|
+ if request_methods and uris and request_methods.include?(request_method.to_sym)
+ uris.each do |u|
+ return true if u.match uri
+ end
+ end
end
end
+ return false
end
end
- return false
end
-
end
end