Class: ArMenuItem

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/ar_menu_item.rb

Overview

Schema information

Table name: ar_menu_item : Menu items

id Integer id created_at Time created_at updated_at Time updated_at caption String Caption of menu item picture String Picture for the menu link String Link called when menu is chosen link_prepend String Link field usually holds direct link to document. Prepand field holds data, that has to be prepanded to the link. target String Target window for the link. Leave empty when same window. page_id Integer Page link order Integer Order on which menu item is shown. Lower number means prior position. hidden Boolean Is hidden active Boolean Is active policy_id Integer Menu item will be diplayed according to this policy parent_id Integer Parent menu item. 0 if top level created_by Integer created_by updated_by Integer updated_by

ArMenuItems model is used to save items of a menu.

Instance Method Summary collapse

Instance Method Details

#cache_deleteObject

Clear parent record from cache



95
96
97
# File 'app/models/ar_menu_item.rb', line 95

def cache_delete
  ArMenu.find(ar_menu_id).cache_delete
end

#do_before_saveObject

Implementation of before_save callback.



88
89
90
# File 'app/models/ar_menu_item.rb', line 88

def do_before_save
  self.link = ArPage.clear_link(caption.downcase.strip) if link.blank?
end

Will return menu path for the item as array of id-s. Method can be used to determine all parents of current item.

Returns: Array. Of parent items ids.



65
66
67
68
69
70
71
72
# File 'app/models/ar_menu_item.rb', line 65

def menu_path
  path, parent = [], self
  while parent
    path << parent.id
    parent = parent._parent
  end 
  path.reverse
end

#top_menu_idObject

Dummy method



81
82
83
# File 'app/models/ar_menu_item.rb', line 81

def top_menu_id
  menu_path[1]
end