Sha256: d0469c31506154c9489352120d6eb9aada44587648c3eb4b92d7ec9914caec52

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module PathHelper
  helpers do
    
    def reset_paths!
      session[:path_ids]   = "home"
      session[:path_names] = "home"
    end
    
    def update_paths!( path_ids, path_names )
      session[:path_ids]   = path_ids
      session[:path_names] = path_names
    end
    
    # Pop paths 1 level
    def back_paths!
      path_ids     = session[:path_ids]
      new_path_ids = path_ids.split( "|" )
      new_path_ids.pop
    
      path_names = session[:path_names]    
      new_path_names = path_names.split( "|" )
      new_path_names.pop
      
      update_paths!( new_path_ids.join( "|" ), new_path_names.join( "|" ) )
    end
    
    # compute title from path    
    def title_for( path_names )
      tokens = path_names.split( "|" )
      buff = case tokens.size
        when 2 : "zone"
        when 3 : "database"
        else     "collection"
      end
      db = tokens.size > 3 ? "<span class=\"ctx\">#{tokens[2]}</span>." : ""
      "<p class=\"ctx\" style=\"text-align:center;font-size:0.8em\">#{db}#{tokens.last}</p>"
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo3-0.0.7 lib/helpers/paths_helper.rb
mongo3-0.0.6 lib/helpers/paths_helper.rb
mongo3-0.0.5 lib/helpers/paths_helper.rb