Class: Avo::Tools::ToolManager

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/tools/tool_manager.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.buildObject



5
6
7
# File 'lib/avo/tools/tool_manager.rb', line 5

def build
  new
end

Instance Method Details

#get_sidebar_partialsObject

Insert any partials that we find in app/views/avo/sidebar/items.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/avo/tools/tool_manager.rb', line 11

def get_sidebar_partials
  tool_sidebar_partials
    .map do |path|
      File.basename path
    end
    .map do |filename|
      # remove the leading underscore (_)
      filename[0] = ""
      # remove the extension
      filename.gsub!(".html.erb", "")
      filename
    end
end

#tool_partialsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/avo/tools/tool_manager.rb', line 29

def tool_partials
  tool_sidebar_partials.map do |filename|
    segments = filename
      .gsub(".html.erb", "")
      .gsub(Rails.root.join("app", "views").to_s, "")
      .split("/")
    last_segment = segments.pop.sub("_", "")

    segments.append last_segment

    segments.join("/")
  end
end

#tools_for_navigationObject



25
26
27
# File 'lib/avo/tools/tool_manager.rb', line 25

def tools_for_navigation
  get_sidebar_partials
end