Class: Renalware::System::AdminMenuComponent
Overview
Experimental ActionView component
Instance Attribute Summary collapse
Instance Method Summary
collapse
#current_user_is_admin?, #current_user_is_developer?, #current_user_is_super_admin?
#policy, #renalware
Constructor Details
Returns a new instance of AdminMenuComponent.
10
11
12
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 10
def initialize(current_user:)
@current_user = current_user
end
|
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
8
9
10
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 8
def current_user
@current_user
end
|
Instance Method Details
14
15
16
17
18
19
20
21
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 14
def (*args)
return unless
current_user_is_admin? ||
current_user_is_super_admin? ||
current_user_is_developer?
(*args)
end
|
#current_controller_matches(regex) ⇒ Object
47
48
49
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 47
def current_controller_matches(regex)
regex.match(params[:controller]).present?
end
|
29
30
31
32
33
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 29
def (*args)
return unless current_user_is_developer?
(*args)
end
|
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 35
def (title, path, active_when_controller_matches, enabled = true)
klasses = %w(link)
klasses << "active" if current_controller_matches(active_when_controller_matches)
content_tag :li, class: klasses.join(" ") do
if enabled
link_to(title, path)
else
content_tag :span, title
end
end
end
|
23
24
25
26
27
|
# File 'app/components/renalware/system/admin_menu_component.rb', line 23
def (*args)
return unless current_user_is_super_admin? || current_user_is_developer?
(*args)
end
|