Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…ible configuration blocks.
  • Loading branch information...
commit 929a7db564e5d5b1124f0fe4f0f69148c905561d 1 parent 23a88eb
Benoit Bénézech bbenezech authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/rails_admin/config/actions/base.rb
11 lib/rails_admin/config/actions/base.rb
View
@@ -25,7 +25,12 @@ 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
@@ -33,10 +38,6 @@ class Base
))
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
Please sign in to comment.
Something went wrong with that request. Please try again.