Module: Couchbase

Defined in:
lib/couchbase.rb,
lib/couchbase/view.rb,
lib/couchbase/error.rb,
lib/couchbase/bucket.rb,
lib/couchbase/cluster.rb,
lib/couchbase/version.rb,
lib/couchbase/document.rb,
lib/couchbase/design_doc.rb,
lib/couchbase/operations.rb,
lib/couchbase/configuration.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: Error, Operations Classes: Bucket, Cluster, Configuration, ConfigurationError, DesignDoc, DesignDocFormatError, Document, View

Constant Summary collapse

VERSION =
'1.0.4'

Class Method Summary collapse

Class Method Details

.bucket(name = nil) ⇒ Object



67
68
69
70
# File 'lib/couchbase.rb', line 67

def bucket(name = nil)
  name ||= :default
  buckets[name.to_sym]
end

.bucketsObject



72
73
74
75
76
77
78
79
80
# File 'lib/couchbase.rb', line 72

def buckets
  @buckets ||= begin
    {}.tap do |buckets|
      @conn.buckets.each do |bucket|
        buckets[bucket.name.to_sym] = cluster.open_bucket(bucket.name, bucket.password)
      end
    end
  end
end

.clusterObject



63
64
65
# File 'lib/couchbase.rb', line 63

def cluster
  @cluster ||= Cluster.new(@conn.hosts)
end

.connected?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/couchbase.rb', line 54

def connected?
  @cluster
end

.connection_options=(options) ⇒ Object



49
50
51
52
# File 'lib/couchbase.rb', line 49

def connection_options=(options)
  fail ConfigurationError, 'Cannot reconfigure an already connected cluster.' if connected?
  @conn = Configuration.new(options)
end

.disconnectObject



58
59
60
61
# File 'lib/couchbase.rb', line 58

def disconnect
  @cluster.disconnect if @cluster
  @buckets = nil
end