Sha256: 162085b5e97bb73d48ed6da6524f8940d3b4b65bb8ec401d66d946cef481b8a6
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 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_id_tokens[count]}"] count += 1 end session[:crumbs] = @crumbs end def pop_crumb!( node_id ) path = "/explore/center/#{node_id}" 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'] ] 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo3-0.0.4 | lib/helpers/crumb_helper.rb |