Module: MongoDoc::Connection
Instance Attribute Summary collapse
- #config_path ⇒ Object
- #env ⇒ Object
- #host ⇒ Object
- #name ⇒ Object
- #options ⇒ Object
- #port ⇒ Object
- #strict ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#config_path ⇒ Object
11 12 13 |
# File 'lib/mongodoc/connection.rb', line 11 def config_path @config_path || default_path end |
#env ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/mongodoc/connection.rb', line 27 def env if rails? Rails.env else @env ||= 'development' end end |
#host ⇒ Object
35 36 37 |
# File 'lib/mongodoc/connection.rb', line 35 def host @host ||= configuration['host'] end |
#name ⇒ Object
39 40 41 |
# File 'lib/mongodoc/connection.rb', line 39 def name @name ||= configuration['name'] || default_name end |
#options ⇒ Object
43 44 45 |
# File 'lib/mongodoc/connection.rb', line 43 def @options ||= configuration['options'] || {} end |
#port ⇒ Object
47 48 49 |
# File 'lib/mongodoc/connection.rb', line 47 def port @port ||= configuration['port'] end |
#strict ⇒ Object
51 52 53 |
# File 'lib/mongodoc/connection.rb', line 51 def strict @strict ||= configuration['strict'] || false end |
Instance Method Details
#configuration ⇒ Object
15 16 17 |
# File 'lib/mongodoc/connection.rb', line 15 def configuration @configuration ||= File.exists?(config_path) ? YAML.load_file(config_path)[env] : {} end |
#connection ⇒ Object
19 20 21 |
# File 'lib/mongodoc/connection.rb', line 19 def connection @connection ||= connect end |
#database ⇒ Object
23 24 25 |
# File 'lib/mongodoc/connection.rb', line 23 def database @database ||= connection.db(name, :strict => strict) end |