Class: Radmin::AdminUI::NavSubItem

Inherits:
Object
  • Object
show all
Defined in:
lib/radmin/admin_ui.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



70
71
72
# File 'lib/radmin/admin_ui.rb', line 70

def name
  @name
end

#tabObject

Returns the value of attribute tab.



71
72
73
# File 'lib/radmin/admin_ui.rb', line 71

def tab
  @tab
end

#urlObject (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_urlObject



89
90
91
# File 'lib/radmin/admin_ui.rb', line 89

def relative_url
  File.join('/', url)
end

#visible?(user) ⇒ Boolean

Returns:

  • (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.authorized?(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