Module: Bread::Helper

Defined in:
lib/bread/helper.rb

Instance Method Summary collapse

Instance Method Details

#breadObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bread/helper.rb', line 4

def bread
  return @bread if @bread

  tmp = nil
  controller._bread_trees.each do |i_action, hash|
    if i_action.to_s == action_name
      tmp = hash
      break
    end
  end

  @bread =  if tmp.nil?
              puts "No Bread for this Action. Please check https://github.com/yakko/bread for more info".light_yellow
              []
            else
              list = []
              while tmp
                arr = controller.instance_eval(&tmp[:block])
                list << {title: arr.first, path: arr.second}
                tmp = tmp[:parent]
              end
              list.reverse
            end
end