module Mumukit::Service::Database

Public Instance Methods

clean!() click to toggle source
# File lib/mumukit/service/database.rb, line 23
def clean!
  client.collections.each(&:drop)
end
config() click to toggle source
# File lib/mumukit/service/database.rb, line 14
def config
  environment = ENV['RACK_ENV'] || 'development'
  @config ||= read_interpolated_yaml('config/database.yml').with_indifferent_access[environment]
end
new_database_client(database) click to toggle source
# File lib/mumukit/service/database.rb, line 6
def new_database_client(database)
  Mongo::Client.new(
      ["#{config[:host]}:#{config[:port]}"],
      database: database,
      user: config[:user],
      password: config[:password])
end
read_interpolated_yaml(filename) click to toggle source
# File lib/mumukit/service/database.rb, line 19
def read_interpolated_yaml(filename)
  YAML.load(ERB.new(File.read(filename)).result)
end