Sha256: f09b2a6d617d28382a98f4dc23f2a7b38ba362627298ca736b5e0e08149bfd80

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

module Bread
  module Helper

    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

  end
end

if defined? ActionView::Base
  ActionView::Base.class_eval do
    include Bread::Helper
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bread-0.0.2 lib/bread/helper.rb
bread-0.0.1 lib/bread/helper.rb