Class: Chroma::ChromaConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/chroma/chroma_configuration.rb

Overview

The ChromaConfiguration class allows you to configure the connection settings for a Chroma service client. It can be initialized directly calling #new method.

Examples

configuration = Chroma::ChromaConfiguration.new
configurarion.connect_host = "https://chroma.example.com"

Or via a setup block.

Examples

Chroma::ChromaConfiguration.setup do |config|
  config.connect_host = "https://chroma.example.com"
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChromaConfiguration

Returns a new instance of ChromaConfiguration.



68
69
70
71
72
73
# File 'lib/chroma/chroma_configuration.rb', line 68

def initialize
  @api_base = "api"
  @api_version = "v1"

  @log_level = Chroma::LEVEL_INFO
end

Instance Attribute Details

#api_baseObject

Sets the base path for the Chroma API.

Examples

config.api_base = "/api"

Returns the String API base path.



36
37
38
# File 'lib/chroma/chroma_configuration.rb', line 36

def api_base
  @api_base
end

#api_versionObject

Sets the version of the Chroma API.

Examples

config.api_version = "v1"

Returns the String API version.



44
45
46
# File 'lib/chroma/chroma_configuration.rb', line 44

def api_version
  @api_version
end

#connect_hostObject

Sets the host name for the Chroma service.

Examples

config.connect_host = "chroma.example.com"

Returns the String host name.



27
28
29
# File 'lib/chroma/chroma_configuration.rb', line 27

def connect_host
  @connect_host
end

#log_levelObject

Sets the logger’s log level for the Chroma service client.

Examples

config.log_level = Chroma::LEVEL_INFO

Returns the log level constant



60
61
62
# File 'lib/chroma/chroma_configuration.rb', line 60

def log_level
  @log_level
end

#loggerObject

Sets the logger for the Chroma service client.

Examples

config.logger = Logger.new(STDOUT)

Returns the Logger instance.



52
53
54
# File 'lib/chroma/chroma_configuration.rb', line 52

def logger
  @logger
end

Class Method Details

.setupObject



62
63
64
65
66
# File 'lib/chroma/chroma_configuration.rb', line 62

def self.setup
  new.tap do |instance|
    yield(instance) if block_given?
  end
end