Module: AutoReconfiguration::Mongo
- Defined in:
- lib/cf-autoconfig/document/mongodb.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply_saved_authentication_with_cf(opts = {}) ⇒ Object
- #db_with_cf(db_name, opts = {}) ⇒ Object
- #initialize_with_cf(host = nil, port = nil, opts = {}) ⇒ Object
- #shortcut_with_cf(db_name) ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/cf-autoconfig/document/mongodb.rb', line 7 def self.included( base ) base.send( :alias_method, :original_initialize, :initialize) base.send( :alias_method, :initialize, :initialize_with_cf ) base.send( :alias_method, :original_apply_saved_authentication, :apply_saved_authentication) base.send( :alias_method, :apply_saved_authentication, :apply_saved_authentication_with_cf ) base.send( :alias_method, :original_db, :db) base.send( :alias_method, :db, :db_with_cf ) base.send( :alias_method, :original_shortcut, :[]) base.send( :alias_method, :[], :shortcut_with_cf ) end |
Instance Method Details
#apply_saved_authentication_with_cf(opts = {}) ⇒ Object
33 34 35 36 |
# File 'lib/cf-autoconfig/document/mongodb.rb', line 33 def apply_saved_authentication_with_cf(opts = {}) add_auth(@service_props[:db], @service_props[:username], @service_props[:password]) original_apply_saved_authentication opts end |
#db_with_cf(db_name, opts = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/cf-autoconfig/document/mongodb.rb', line 38 def db_with_cf(db_name, opts = {}) if @auto_config && db_name != 'admin' add_auth(@service_props[:db], @service_props[:username], @service_props[:password]) db = original_db @service_props[:db], opts else original_db db_name, opts end end |
#initialize_with_cf(host = nil, port = nil, opts = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cf-autoconfig/document/mongodb.rb', line 18 def initialize_with_cf(host = nil, port = nil, opts = {}) service_names = CFRuntime::CloudApp.service_names_of_type('mongodb') if service_names.length == 1 @service_props = CFRuntime::CloudApp.service_props('mongodb') puts "Auto-reconfiguring MongoDB" @auto_config = true original_initialize @service_props[:host], @service_props[:port], opts add_auth(@service_props[:db], @service_props[:username], @service_props[:password]) else puts "Found #{service_names.length} mongo services. Skipping auto-reconfiguration." @auto_config = false original_initialize host, port, opts end end |
#shortcut_with_cf(db_name) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/cf-autoconfig/document/mongodb.rb', line 47 def shortcut_with_cf(db_name) if @auto_config && db_name != 'admin' add_auth(@service_props[:db], @service_props[:username], @service_props[:password]) db = original_shortcut(@service_props[:db]) else db = original_shortcut(db_name) end end |