Skip to content

Commit

Permalink
Merge pull request #103 from Mapotempo/accept_connection_string_with_tls
Browse files Browse the repository at this point in the history
accept connection string with TLS
  • Loading branch information
giallon authored Feb 11, 2025
2 parents 0c3cbd2 + 54c1d66 commit 3971899
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/couchbase-orm/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ def self.config=(config)
def self.cluster
@cluster ||= begin
cb_config = Couchbase::Configuration.new
cb_config.connection_string = config[:connection_string].presence.try { |s|
"couchbase://#{s}"
} || raise(CouchbaseOrm::Error.new('Missing CouchbaseOrm host'))
cb_config.connection_string = config[:connection_string].presence.try do |s|
if s.start_with?('couchbase://', 'couchbases://')
s
else
"couchbase://#{s}"
end
end || raise(CouchbaseOrm::Error.new('Missing CouchbaseOrm host'))
cb_config.username = config[:username].presence || raise(CouchbaseOrm::Error.new('Missing CouchbaseOrm username'))
cb_config.password = config[:password].presence || raise(CouchbaseOrm::Error.new('Missing CouchbaseOrm password'))
Couchbase::Cluster.connect(cb_config)
Expand Down

0 comments on commit 3971899

Please sign in to comment.