Module: WingedCouch::Configuration

Included in:
WingedCouch
Defined in:
lib/winged_couch/configuration.rb

Overview

Main configuration module

Examples:

Usage:

WingedCouch.setup do |config|
  config.host = "couch-db-host.com"
  config.port = 1234
end

WingedCouch.host
# => "couch-db-host.com"

WingedCouch.port
# => 1234

WingedCouch.reset_configuration!
# => nil

WingedCouch.host
# => "127.0.0.1"

WingedCouch.port
# => 5984

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostString

Returns CouchDB host

Returns:

  • (String)

38
39
40
# File 'lib/winged_couch/configuration.rb', line 38

def host
  @host ||= ENV["COUCHDB_HOST"] || "127.0.0.1"
end

#loggerObject

Returns the value of attribute logger


32
33
34
# File 'lib/winged_couch/configuration.rb', line 32

def logger
  @logger
end

#portFixnum

Returns CouchDB port

Returns:

  • (Fixnum)

46
47
48
# File 'lib/winged_couch/configuration.rb', line 46

def port
  @port ||= ENV["COUCHDB_PORT"] || "5984"
end

Instance Method Details

#inspectObject Also known as: to_s, to_str


61
62
63
# File 'lib/winged_couch/configuration.rb', line 61

def inspect
  "#<WingedCouch connected to #{url}>"
end

#reset_configuration!Object

Resets configuration to default


80
81
82
83
# File 'lib/winged_couch/configuration.rb', line 80

def reset_configuration!
  @host = nil
  @port = nil
end

#setup { ... } ⇒ Object

Main configuration method

Yields:

  • config

Returns:

  • config


73
74
75
76
# File 'lib/winged_couch/configuration.rb', line 73

def setup
  yield self
  self
end

#urlString

Returns CouchDB url (based on 'host' and 'port' attributes)

Returns:

  • (String)

55
56
57
# File 'lib/winged_couch/configuration.rb', line 55

def url
  "#{host}:#{port}"
end