Module: SimpleMetrics::Repository
Instance Method Summary collapse
- #config ⇒ Object
- #connection ⇒ Object
- #db ⇒ Object
- #db_name ⇒ Object
- #host ⇒ Object
- #port ⇒ Object
- #prefix ⇒ Object
Instance Method Details
#config ⇒ Object
29 30 31 |
# File 'lib/simple_metrics/repository.rb', line 29 def config SimpleMetrics.config.db end |
#connection ⇒ Object
5 6 7 |
# File 'lib/simple_metrics/repository.rb', line 5 def connection @@connection ||= ::Mongo::Connection.new(host, port) end |
#db ⇒ Object
9 10 11 |
# File 'lib/simple_metrics/repository.rb', line 9 def db @@db ||= connection.db(db_name, config.fetch(:options)) end |
#db_name ⇒ Object
13 14 15 |
# File 'lib/simple_metrics/repository.rb', line 13 def db_name "simple_metrics_#{prefix}" end |
#host ⇒ Object
21 22 23 |
# File 'lib/simple_metrics/repository.rb', line 21 def host config[:host] || 'localhost' end |
#port ⇒ Object
25 26 27 |
# File 'lib/simple_metrics/repository.rb', line 25 def port config[:port] || 27017 end |
#prefix ⇒ Object
17 18 19 |
# File 'lib/simple_metrics/repository.rb', line 17 def prefix config[:prefix] || 'development' end |