# This is a replacement of the couchbase settings gem. The quality of this gem is not sufficient to
# work with. Since couchbase structures/docstore are using CouchbaseSetting we supply the right settings
# here

module CouchbaseSetting
  mattr_accessor :config_type
  mattr_accessor :configs

  def self.server
    config :server, default: '127.0.0.1'
  end

  def self.bucket
    config :bucket, default: 'qwaiter'
  end

  def self.config(setting, default: nil)
    configs[config_type][Rails.env.to_sym][setting] || default
  end
end

CouchbaseSetting.configs = {
  supplier_counters: {
    development: {
      bucket: 'qwaiter_development'
    },
    test:{
      bucket: 'qwaiter_development'
    },
    production: {}
  },
  queue: {
    development: {
      bucket: 'qwaiter_development'
    },
    test:{
      bucket: 'qwaiter_development'
    },
    production: {}
  }
}

# only one in use at the moment
CouchbaseSetting.config_type = :supplier_counters
