Class: ClickHouse::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/click_house/config.rb

Constant Summary collapse

DEFAULT_SCHEME =
'http'
DEFAULT_HOST =
'localhost'
DEFAULT_PORT =
'8123'
DEFAULTS =
{
  adapter: Faraday.default_adapter,
  url: nil,
  scheme: 'http',
  host: 'localhost',
  port: '8123',
  logger: nil,
  database: nil,
  username: nil,
  password: nil,
  timeout: nil,
  open_timeout: nil,
  ssl_verify: false
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



37
38
39
40
# File 'lib/click_house/config.rb', line 37

def initialize(params = {})
  assign(DEFAULTS.merge(params))
  yield(self) if block_given?
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



24
25
26
# File 'lib/click_house/config.rb', line 24

def adapter
  @adapter
end

#databaseObject

Returns the value of attribute database.



29
30
31
# File 'lib/click_house/config.rb', line 29

def database
  @database
end

#hostObject

Returns the value of attribute host.



27
28
29
# File 'lib/click_house/config.rb', line 27

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



25
26
27
# File 'lib/click_house/config.rb', line 25

def logger
  @logger
end

#open_timeoutObject

Returns the value of attribute open_timeout.



34
35
36
# File 'lib/click_house/config.rb', line 34

def open_timeout
  @open_timeout
end

#passwordObject

Returns the value of attribute password.



32
33
34
# File 'lib/click_house/config.rb', line 32

def password
  @password
end

#portObject

Returns the value of attribute port.



28
29
30
# File 'lib/click_house/config.rb', line 28

def port
  @port
end

#schemeObject

Returns the value of attribute scheme.



26
27
28
# File 'lib/click_house/config.rb', line 26

def scheme
  @scheme
end

#ssl_verifyObject

Returns the value of attribute ssl_verify.



35
36
37
# File 'lib/click_house/config.rb', line 35

def ssl_verify
  @ssl_verify
end

#timeoutObject

Returns the value of attribute timeout.



33
34
35
# File 'lib/click_house/config.rb', line 33

def timeout
  @timeout
end

#urlObject

Returns the value of attribute url.



30
31
32
# File 'lib/click_house/config.rb', line 30

def url
  @url
end

#usernameObject

Returns the value of attribute username.



31
32
33
# File 'lib/click_house/config.rb', line 31

def username
  @username
end

Instance Method Details

#assign(params = {}) ⇒ self

Returns:

  • (self)


43
44
45
46
47
# File 'lib/click_house/config.rb', line 43

def assign(params = {})
  params.each { |k, v| public_send("#{k}=", v) }

  self
end

#auth?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/click_house/config.rb', line 49

def auth?
  !username.nil? || !password.nil?
end

#logger!Object



53
54
55
# File 'lib/click_house/config.rb', line 53

def logger!
  @logger || Logger.new('/dev/null')
end

#url!Object



57
58
59
# File 'lib/click_house/config.rb', line 57

def url!
  @url || "#{scheme}://#{host}:#{port}"
end