module TokyoMetro::Modules::Db::Model

Constants

GROUP

Public Class Methods

list() click to toggle source
# File lib/tokyo_metro/modules/db/model.rb, line 7
def self.list
  make_list( group )
end
list_sort_by_alphabet() click to toggle source
# File lib/tokyo_metro/modules/db/model.rb, line 11
def self.list_sort_by_alphabet
  make_list( { "All" => group.values.flatten.sort } )
end

Private Class Methods

make_list(h) click to toggle source
# File lib/tokyo_metro/modules/db/model.rb, line 19
def make_list(h)
  model_ary = ::Array.new
  h.each do | category , models |
    models.each.with_index(1) do | model , i |
      if i == 1
        category_name = category
      else
        category_name = nil
      end

      model_ary << { category: category_name , model: model , count: eval( "::#{ model }.all.count" ) }
    end
  end
  model_ary
end