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/jruby/future.rb,
lib/couchbase/async/callback.rb,
lib/couchbase/jruby/couchbase_client.rb
Overview
- Author
-
Couchbase <[email protected]>
- Copyright
-
2011-2012 Couchbase, Inc.
- 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, Jruby, Operations, Transcoder Classes: Bucket, Cluster, DesignDoc, Query, Result, Utils, View, ViewRow
Constant Summary collapse
- VERSION =
'0.1.1'- @@buckets =
Atomic.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
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
Class Attribute Details
.connection_options ⇒ Hash, String
Default connection options
87 88 89 |
# File 'lib/couchbase.rb', line 87 def end |
Class Method Details
.bucket(name = nil) ⇒ Bucket
The connection instance for current thread
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/couchbase.rb', line 122 def bucket(name = nil) name ||= case when Hash [:bucket] when String path = URI.parse().path path[%r(^(/pools/([A-Za-z0-9_.-]+)(/buckets/([A-Za-z0-9_.-]+))?)?), 3] || "default" else "default" end @@buckets.update { |buckets| buckets[name] ||= connect() } @@buckets.value[name] end |
.bucket=(connection) ⇒ Bucket
Set a connection instance for current thread
141 142 143 144 145 |
# File 'lib/couchbase.rb', line 141 def bucket=(connection) name ||= && [:bucket] || "default" @@buckets.update { |buckets| buckets[name] = connection } @@buckets.value[name] end |
.connect(*options) ⇒ Bucket Also known as: new
The method connect initializes new Bucket instance with all arguments passed.
70 71 72 73 74 75 |
# File 'lib/couchbase.rb', line 70 def connect(*) Bucket.new(*(.flatten)) # disconnect # @@bucket.update { |bucket| bucket ||= Bucket.new(*(options.flatten)) } # @@bucket.value end |
.connected? ⇒ Boolean
147 148 149 |
# File 'lib/couchbase.rb', line 147 def connected? !!@@buckets.value.empty? end |
.disconnect ⇒ Object
151 152 153 154 |
# File 'lib/couchbase.rb', line 151 def disconnect @@buckets.value.each(&:disconnect) if connected? @@buckets = Atomic.new({}) end |