Class: Radmin::AdminUI::NavSubItem
- Inherits:
-
Object
- Object
- Radmin::AdminUI::NavSubItem
- Defined in:
- lib/radmin/admin_ui.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tab ⇒ Object
Returns the value of attribute tab.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(name, url = "#") ⇒ NavSubItem
constructor
A new instance of NavSubItem.
- #relative_url ⇒ Object
- #visible?(user) ⇒ Boolean
Constructor Details
#initialize(name, url = "#") ⇒ NavSubItem
Returns a new instance of NavSubItem.
73 74 75 |
# File 'lib/radmin/admin_ui.rb', line 73 def initialize(name, url = "#") @name, @url = name, url end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
70 71 72 |
# File 'lib/radmin/admin_ui.rb', line 70 def name @name end |
#tab ⇒ Object
Returns the value of attribute tab.
71 72 73 |
# File 'lib/radmin/admin_ui.rb', line 71 def tab @tab end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
70 71 72 |
# File 'lib/radmin/admin_ui.rb', line 70 def url @url end |
Instance Method Details
#relative_url ⇒ Object
89 90 91 |
# File 'lib/radmin/admin_ui.rb', line 89 def relative_url File.join('/', url) end |
#visible?(user) ⇒ Boolean
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/radmin/admin_ui.rb', line 77 def visible?(user) params = Rails.application.routes.recognize_path(url, :method => :get) if params && params[:controller] resource = params[:controller].demodulize.sub("Controller", "").underscore.split('/').last.singularize Radmin::Authorization.(user, params[:action], "Radmin::#{resource.capitalize}".constantize) rescue true #ctx = params[:controller].sub('/','_').to_sym #Authorization::Engine.instance.permit?(params[:action], :context => ctx, :user => user) else false end end |