Class: MenuItems

Inherits:
Object
  • Object
show all
Defined in:
app/services/menu_service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_actionObject

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_objectObject

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

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

#iconObject

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

#itemsObject

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

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_requiredObject

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
end

#nameObject

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

#pathObject

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

#titleObject

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

#urlObject

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_pathObject



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

Returns:

  • (Boolean)


45
46
47
# File 'app/services/menu_service.rb', line 45

def 
  !self.
end