Browse files

refactor authorized/visible to make authorized easier to reuse in vis…

…ible configuration blocks.
  • Loading branch information...
1 parent 23a88eb commit 929a7db564e5d5b1124f0fe4f0f69148c905561d @bbenezech bbenezech committed Sep 18, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/rails_admin/config/actions/base.rb
View
11 lib/rails_admin/config/actions/base.rb
@@ -25,18 +25,19 @@ class Base
# Should the action be visible
register_instance_option :visible? do
- authorized? and (
+ authorized?
+ end
+
+ register_instance_option :authorized? do
+ (
+ bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])) and (
bindings[:abstract_model].nil? or (
(only.nil? or [only].flatten.map(&:to_s).include?(bindings[:abstract_model].model.to_s)) and
![except].flatten.map(&:to_s).include?(bindings[:abstract_model].model.to_s) and
bindings[:abstract_model].config.with(bindings).visible?
))
end
- register_instance_option :authorized? do
- bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])
- end
-
# Is the action acting on the root level (Example: /admin/contact)
register_instance_option :root? do
false

0 comments on commit 929a7db

Please sign in to comment.