Class: Effective::MenuItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::MenuItem
- Defined in:
- app/models/effective/menu_item.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
This gets set on the Root node and a node created by Dropdown, so the item function knows whether to go down or to go accross.
Instance Method Summary collapse
- #divider? ⇒ Boolean
- #dropdown? ⇒ Boolean
- #leaf? ⇒ Boolean
-
#visible_for?(user) ⇒ Boolean
For now it’s just logged in or not? This will work with effective_roles one day…
Instance Attribute Details
#parent ⇒ Object
This gets set on the Root node and a node created by Dropdown, so the item function knows whether to go down or to go accross
3 4 5 |
# File 'app/models/effective/menu_item.rb', line 3 def parent @parent end |
Instance Method Details
#divider? ⇒ Boolean
45 46 47 |
# File 'app/models/effective/menu_item.rb', line 45 def divider? leaf? && special == 'divider' end |
#dropdown? ⇒ Boolean
41 42 43 |
# File 'app/models/effective/menu_item.rb', line 41 def dropdown? !leaf? end |
#leaf? ⇒ Boolean
37 38 39 |
# File 'app/models/effective/menu_item.rb', line 37 def leaf? (rgt.to_i - lft.to_i) == 1 end |
#visible_for?(user) ⇒ Boolean
For now it’s just logged in or not? This will work with effective_roles one day…
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/effective/menu_item.rb', line 51 def visible_for?(user) can_view_page = ( if dropdown? true elsif .kind_of?(Effective::Page) .roles_permit?(user) else true end ) = ( if roles_mask == nil true elsif roles_mask == -1 # Am I logged out? user.blank? elsif roles_mask == 0 # Am I logged in? user.present? else roles_permit?(user) end ) can_view_page && end |