Sha256: be1e0758b21ad69eaa28f2cfea2a1e35b788fc1450c0825531bdb560ec08ebed

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 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

2 entries across 2 versions & 1 rubygems

Version Path
mongo3-0.0.9 lib/helpers/paths_helper.rb
mongo3-0.0.8 lib/helpers/paths_helper.rb