Module: Couchbase
- Defined in:
- lib/couchbase.rb,
lib/couchbase/view.rb,
lib/couchbase/async.rb,
lib/couchbase/error.rb,
lib/couchbase/query.rb,
lib/couchbase/utils.rb,
lib/couchbase/bucket.rb,
lib/couchbase/result.rb,
lib/couchbase/cluster.rb,
lib/couchbase/version.rb,
lib/couchbase/view_row.rb,
lib/couchbase/constants.rb,
lib/couchbase/design_doc.rb,
lib/couchbase/operations.rb,
lib/couchbase/transcoder.rb,
lib/couchbase/async/queue.rb,
lib/couchbase/async/callback.rb
Overview
- Author
Mike Evans [email protected]
- Copyright
2013 Urlgonomics LLC.
- License
Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: Async, Constants, Error, Operations, Transcoder Classes: Bucket, Cluster, ClusterError, DesignDoc, Query, Result, Utils, View, ViewRow
Constant Summary collapse
- VERSION =
'0.1.8'- @@buckets =
ThreadSafe::Cache.new
Class Attribute Summary collapse
-
.connection_options ⇒ Hash, String
Default connection options.
Class Method Summary collapse
-
.bucket(name = nil) ⇒ Bucket
The connection instance for current thread.
-
.bucket=(connection) ⇒ Bucket
(also: set_bucket)
Set a connection instance for current thread.
-
.connect(*options) ⇒ Bucket
(also: new)
The method
connectinitializes new Bucket instance with all arguments passed. - .connected? ⇒ Boolean
- .disconnect ⇒ Object
- .normalize_connection_options(options) ⇒ Object
Class Attribute Details
.connection_options ⇒ Hash, String
Default connection options
98 99 100 |
# File 'lib/couchbase.rb', line 98 def @connection_options end |
Class Method Details
.bucket(name = nil) ⇒ Bucket
The connection instance for current thread
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/couchbase.rb', line 141 def bucket(name = nil) name ||= case @connection_options when Hash @connection_options[:bucket] when String path = URI.parse(@connection_options).path path[%r(^(/pools/([A-Za-z0-9_.-]+)(/buckets/([A-Za-z0-9_.-]+))?)?), 3] || 'default' else 'default' end @@buckets[name] ||= connect() end |
.bucket=(connection) ⇒ Bucket Also known as: set_bucket
Set a connection instance for current thread
160 161 162 163 |
# File 'lib/couchbase.rb', line 160 def bucket=(connection) name = @connection_options && @connection_options[:bucket] || "default" @@buckets[name] = connection end |
.connect(*options) ⇒ Bucket Also known as: new
The method connect initializes new Bucket instance with all arguments passed.
84 85 86 |
# File 'lib/couchbase.rb', line 84 def connect(*) Bucket.new(*(.flatten)) end |
.connected? ⇒ Boolean
166 167 168 |
# File 'lib/couchbase.rb', line 166 def connected? !!@@buckets.empty? end |
.disconnect ⇒ Object
170 171 172 173 174 175 176 |
# File 'lib/couchbase.rb', line 170 def disconnect @@buckets.each_key do |name| bucket = @@buckets.delete(name) bucket.disconnect end @@buckets = ThreadSafe::Cache.new end |
.normalize_connection_options(options) ⇒ Object
104 105 106 |
# File 'lib/couchbase.rb', line 104 def () Hash[ .map { |k, v| [k.to_sym, v] } ] end |