store management
# File lib/trocla/stores.rb, line 5 def [](store) stores[store.to_s.downcase] end
# File lib/trocla/stores.rb, line 9 def all @all ||= Dir[ path '*' ].collect do |store| File.basename(store, '.rb').downcase end end
# File lib/trocla/stores.rb, line 15 def available?(store) all.include?(store.to_s.downcase) end
# File lib/trocla/stores.rb, line 33 def path(store) File.expand_path( File.join(File.dirname(__FILE__), 'stores', "#{store}.rb") ) end
# File lib/trocla/stores.rb, line 20 def stores @@stores ||= Hash.new do |hash, store| store = store.to_s.downcase if File.exists?(path(store)) require "trocla/stores/#{store}" class_name = "Trocla::Stores::#{store.capitalize}" hash[store] = (eval class_name) else raise "Store #{store} is not supported!" end end end