Class: Couchbase::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/configuration.rb

Defined Under Namespace

Classes: Bucket

Constant Summary collapse

DEFAULT_CONFIG =
{
  host:     'localhost',
  bucket:   'default',
  password: ''
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Configuration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/couchbase/configuration.rb', line 15

def initialize(config = {})
  config = DEFAULT_CONFIG.merge(symbolize_keys(config))
  @hosts = Array(config[:hosts] || config[:host] || config[:hostname])

  if config[:buckets]
    @buckets = config[:buckets].map do |b|
      b = symbolize_keys(b)
      Bucket.new(b[:name], b[:password])
    end
  else
    @buckets = [Bucket.new(config[:bucket], config[:password])]
  end
end

Instance Attribute Details

#bucketsObject

Returns the value of attribute buckets.



13
14
15
# File 'lib/couchbase/configuration.rb', line 13

def buckets
  @buckets
end

#hostsObject

Returns the value of attribute hosts.



13
14
15
# File 'lib/couchbase/configuration.rb', line 13

def hosts
  @hosts
end