Class: Fae::Navigation

Inherits:
Object
  • Object
show all
Includes:
NavigationConcern
Defined in:
app/models/fae/navigation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NavigationConcern

#structure

Constructor Details

#initialize(current_user) ⇒ Navigation

Returns a new instance of Navigation.



8
9
10
11
# File 'app/models/fae/navigation.rb', line 8

def initialize(current_user)
  @current_user = current_user
  @items = recursive_authorization(structure)
end

Instance Attribute Details

#coordinatesObject

Returns the value of attribute coordinates.



6
7
8
# File 'app/models/fae/navigation.rb', line 6

def coordinates
  @coordinates
end

#current_pathObject

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_userObject

Returns the value of attribute current_user.



6
7
8
# File 'app/models/fae/navigation.rb', line 6

def current_user
  @current_user
end

#itemsObject

Returns the value of attribute items.



6
7
8
# File 'app/models/fae/navigation.rb', line 6

def items
  @items
end

Instance Method Details

#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(current_path) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/models/fae/navigation.rb', line 13

def side_nav(current_path)
  @current_path = current_path
  # set the coors based on current path
  @coordinates = []
  find_current_hash(@items)

  @items[@coordinates.first][:subitems][@coordinates.second][:subitems] if @coordinates.length > 2
end