Sha256: 535e48076cd9329f1f555b15bf7fff1fe481064c8308f8dd172403d3899d354c
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module CrumbHelper helpers do def crumbs_from_path( path_ids, path_names ) path_id_tokens = path_ids.split( "|" ) path_name_tokens = path_names.split( "|" ) @crumbs = [] count = 0 path_name_tokens.each do |crumb| @crumbs << [crumb, "/explore/center/#{path_name_tokens[0..count].join( "|" )}/#{path_id_tokens[0..count].join( "|") }"] count += 1 end session[:crumbs] = @crumbs end def pop_crumb!( path_ids, path_names ) path = "/explore/center/#{path_ids}/#{path_names}" level = 0 range = nil @crumbs.each do |pair| if pair.last == path range = level break end level += 1 end @crumbs = ( range > 0 ? @crumbs[0..range] : [@crumbs[0]] ) session[:crumbs] = @crumbs end def reset_crumbs! @crumbs = [ ["home", '/explore/center/home/home'] ] session[:crumbs] = @crumbs end def add_crumb( title, url ) titles = @crumbs.map{ |p| p.first } unless titles.include?( title ) @crumbs.pop if @crumbs.size == 3 @crumbs << [title, url] session[:crumbs] = @crumbs end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongo3-0.0.7 | lib/helpers/crumb_helper.rb |
mongo3-0.0.6 | lib/helpers/crumb_helper.rb |
mongo3-0.0.5 | lib/helpers/crumb_helper.rb |