Class: MenuItems
- Inherits:
-
Object
- Object
- MenuItems
- Defined in:
- app/services/menu_service.rb
Instance Attribute Summary collapse
-
#ability_action ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#ability_object ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#dropdown ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#icon ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#items ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#link ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#login_required ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#name ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#path ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#title ⇒ Object
menu items are cached, we clear this cache when booting the apps.
-
#url ⇒ Object
menu items are cached, we clear this cache when booting the apps.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(h) ⇒ MenuItems
constructor
A new instance of MenuItems.
- #login_not_required? ⇒ Boolean
Constructor Details
#initialize(h) ⇒ MenuItems
Returns a new instance of MenuItems.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/menu_service.rb', line 17 def initialize(h) h.each {|k,v| public_send("#{k}=",v)} self.ability_action = h["ability_action"].parameterize.underscore.to_sym self.ability_object = h["ability_object"].parameterize.underscore.to_sym # items is a Menu item collection self.items = [] if h["items"] h["items"].each do |item| self.items << MenuItems.new(item) end end # set link to path unless url is present self.path ? self.link = eval('Rails.application.routes.url_helpers.'+self.path) : self.link = self.url end |
Instance Attribute Details
#ability_action ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def ability_action @ability_action end |
#ability_object ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def ability_object @ability_object end |
#dropdown ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def dropdown @dropdown end |
#icon ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def icon @icon end |
#items ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def items @items end |
#link ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def link @link end |
#login_required ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def login_required @login_required end |
#name ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def name @name end |
#path ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def path @path end |
#title ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def title @title end |
#url ⇒ Object
menu items are cached, we clear this cache when booting the apps
4 5 6 |
# File 'app/services/menu_service.rb', line 4 def url @url end |
Class Method Details
.all(config_file = MenuItems::MENU_CONFIG) ⇒ Object
39 40 41 42 43 |
# File 'app/services/menu_service.rb', line 39 def self.all(config_file = MenuItems::MENU_CONFIG) Rails.cache.fetch("menu_items_all") do config_file.map{|item| MenuItems.new(item) } end end |
.logo_path ⇒ Object
49 50 51 |
# File 'app/services/menu_service.rb', line 49 def self.logo_path defined?(APP_LOGO_PATH) ? APP_LOGO_PATH : "gorg_engine/logo_alumni.jpg" end |
Instance Method Details
#login_not_required? ⇒ Boolean
45 46 47 |
# File 'app/services/menu_service.rb', line 45 def login_not_required? !self.login_required end |