Class: AmaLayout::Navigation
- Inherits:
-
Object
- Object
- AmaLayout::Navigation
- Includes:
- ActiveModel::Model
- Defined in:
- lib/ama_layout/navigation.rb
Instance Attribute Summary collapse
-
#current_url ⇒ Object
Returns the value of attribute current_url.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#nav_file_path ⇒ Object
Returns the value of attribute nav_file_path.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #decorate ⇒ Object
- #email ⇒ Object
-
#initialize(args = {}) ⇒ Navigation
constructor
A new instance of Navigation.
- #items ⇒ Object
- #navigation_items ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Navigation
Returns a new instance of Navigation.
13 14 15 16 |
# File 'lib/ama_layout/navigation.rb', line 13 def initialize(args = {}) args = defaults.merge args super end |
Instance Attribute Details
#current_url ⇒ Object
Returns the value of attribute current_url.
11 12 13 |
# File 'lib/ama_layout/navigation.rb', line 11 def current_url @current_url end |
#display_name ⇒ Object
Returns the value of attribute display_name.
11 12 13 |
# File 'lib/ama_layout/navigation.rb', line 11 def display_name @display_name end |
#nav_file_path ⇒ Object
Returns the value of attribute nav_file_path.
11 12 13 |
# File 'lib/ama_layout/navigation.rb', line 11 def nav_file_path @nav_file_path end |
#user ⇒ Object
Returns the value of attribute user.
11 12 13 |
# File 'lib/ama_layout/navigation.rb', line 11 def user @user end |
Instance Method Details
#decorate ⇒ Object
7 8 9 |
# File 'lib/ama_layout/navigation.rb', line 7 def decorate AmaLayout::NavigationDecorator.new(self) end |
#email ⇒ Object
48 49 50 |
# File 'lib/ama_layout/navigation.rb', line 48 def email user.email end |
#items ⇒ Object
38 39 40 41 42 |
# File 'lib/ama_layout/navigation.rb', line 38 def items .fetch(user.try(:navigation), []).map do |n| NavigationItem.new n.merge(current_url: current_url) end end |
#navigation_items ⇒ Object
44 45 46 |
# File 'lib/ama_layout/navigation.rb', line 44 def YAML.safe_load(ERB.new(File.read(nav_file_path)).result) end |