Module: MongoDoc::Connection
Instance Attribute Summary collapse
- #config_path ⇒ Object
- #default_name ⇒ 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/mongo_doc/connection.rb', line 11 def config_path @config_path || './mongodb.yml' end |
#default_name ⇒ Object
27 28 29 |
# File 'lib/mongo_doc/connection.rb', line 27 def default_name @default_name ||= "mongo_doc" end |
#env ⇒ Object
31 32 33 |
# File 'lib/mongo_doc/connection.rb', line 31 def env @env ||= 'development' end |
#host ⇒ Object
35 36 37 |
# File 'lib/mongo_doc/connection.rb', line 35 def host @host ||= configuration['host'] end |
#name ⇒ Object
39 40 41 |
# File 'lib/mongo_doc/connection.rb', line 39 def name @name ||= configuration['name'] || default_name end |
#options ⇒ Object
43 44 45 |
# File 'lib/mongo_doc/connection.rb', line 43 def @options ||= configuration['options'] || {} end |
#port ⇒ Object
47 48 49 |
# File 'lib/mongo_doc/connection.rb', line 47 def port @port ||= configuration['port'] end |
#strict ⇒ Object
51 52 53 |
# File 'lib/mongo_doc/connection.rb', line 51 def strict @strict ||= configuration['strict'] || false end |
Instance Method Details
#configuration ⇒ Object
15 16 17 |
# File 'lib/mongo_doc/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/mongo_doc/connection.rb', line 19 def connection @connection ||= connect end |
#database ⇒ Object
23 24 25 |
# File 'lib/mongo_doc/connection.rb', line 23 def database @database ||= connection.db(name, :strict => strict) end |