Class: AmaLayout::Navigation
- Inherits:
-
Object
- Object
- AmaLayout::Navigation
- Includes:
- ActiveModel::Model, Draper::Decoratable
- 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
- #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.
8 9 10 11 |
# File 'lib/ama_layout/navigation.rb', line 8 def initialize(args = {}) args = defaults.merge args super end |
Instance Attribute Details
#current_url ⇒ Object
Returns the value of attribute current_url.
6 7 8 |
# File 'lib/ama_layout/navigation.rb', line 6 def current_url @current_url end |
#display_name ⇒ Object
Returns the value of attribute display_name.
6 7 8 |
# File 'lib/ama_layout/navigation.rb', line 6 def display_name @display_name end |
#nav_file_path ⇒ Object
Returns the value of attribute nav_file_path.
6 7 8 |
# File 'lib/ama_layout/navigation.rb', line 6 def nav_file_path @nav_file_path end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/ama_layout/navigation.rb', line 6 def user @user end |
Instance Method Details
#email ⇒ Object
36 37 38 |
# File 'lib/ama_layout/navigation.rb', line 36 def email user.email end |
#items ⇒ Object
26 27 28 29 30 |
# File 'lib/ama_layout/navigation.rb', line 26 def items .fetch(user.try(:navigation), []).map do |n| NavigationItem.new n.merge({ current_url: current_url}) end end |
#navigation_items ⇒ Object
32 33 34 |
# File 'lib/ama_layout/navigation.rb', line 32 def YAML.load ERB.new(File.read nav_file_path).result end |