Class: Fae::Navigation
- Inherits:
-
Object
- Object
- Fae::Navigation
- Includes:
- NavigationConcern
- Defined in:
- app/models/fae/navigation.rb
Instance Attribute Summary collapse
-
#coordinates ⇒ Object
Returns the value of attribute coordinates.
-
#current_path ⇒ Object
Returns the value of attribute current_path.
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
- #current_section ⇒ Object
-
#initialize(current_path, current_user) ⇒ Navigation
constructor
A new instance of Navigation.
- #search(query) ⇒ Object
- #side_nav ⇒ Object
Methods included from NavigationConcern
Constructor Details
#initialize(current_path, current_user) ⇒ Navigation
Returns a new instance of Navigation.
8 9 10 11 12 13 14 15 16 |
# File 'app/models/fae/navigation.rb', line 8 def initialize(current_path, current_user) @current_path = current_path @current_user = current_user @coordinates = [] @items = (structure) # set the coors based on current path find_current_hash(@items) end |
Instance Attribute Details
#coordinates ⇒ Object
Returns the value of attribute coordinates.
6 7 8 |
# File 'app/models/fae/navigation.rb', line 6 def coordinates @coordinates end |
#current_path ⇒ Object
Returns the value of attribute current_path.
6 7 8 |
# File 'app/models/fae/navigation.rb', line 6 def current_path @current_path end |
#current_user ⇒ Object
Returns the value of attribute current_user.
6 7 8 |
# File 'app/models/fae/navigation.rb', line 6 def current_user @current_user end |
#items ⇒ Object
Returns the value of attribute items.
6 7 8 |
# File 'app/models/fae/navigation.rb', line 6 def items @items end |
Instance Method Details
#current_section ⇒ Object
26 27 28 |
# File 'app/models/fae/navigation.rb', line 26 def current_section @current_path.gsub(/\/new$|\/\d+\/edit/, '') end |
#search(query) ⇒ Object
22 23 24 |
# File 'app/models/fae/navigation.rb', line 22 def search(query) find_items_by_text(@items, query, []) end |
#side_nav ⇒ Object
18 19 20 |
# File 'app/models/fae/navigation.rb', line 18 def side_nav @items[@coordinates.first][:subitems][@coordinates.second][:subitems] if @coordinates.length > 2 end |