Module: SimpleMetrics::Repository

Extended by:
Repository
Included in:
Repository
Defined in:
lib/simple_metrics/repository.rb

Instance Method Summary collapse

Instance Method Details

#configObject



29
30
31
# File 'lib/simple_metrics/repository.rb', line 29

def config
  SimpleMetrics.config.db
end

#connectionObject



5
6
7
# File 'lib/simple_metrics/repository.rb', line 5

def connection
  @@connection ||= ::Mongo::Connection.new(host, port)
end

#dbObject



9
10
11
# File 'lib/simple_metrics/repository.rb', line 9

def db
  @@db ||= connection.db(db_name, config.fetch(:options))
end

#db_nameObject



13
14
15
# File 'lib/simple_metrics/repository.rb', line 13

def db_name
  "simple_metrics_#{prefix}"
end

#hostObject



21
22
23
# File 'lib/simple_metrics/repository.rb', line 21

def host
  config[:host] || 'localhost'
end

#portObject



25
26
27
# File 'lib/simple_metrics/repository.rb', line 25

def port
  config[:port] || 27017
end

#prefixObject



17
18
19
# File 'lib/simple_metrics/repository.rb', line 17

def prefix
  config[:prefix] || 'development'
end