Class: Eli::Config

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

Overview

Documentation for Eli::Config.

Holds the configuration used by the library, the most important being the base URL of the Letmein server the client talks to.

Constant Summary collapse

DEFAULT_BASE_URL =
"http://localhost:4000"

Class Method Summary collapse

Class Method Details

.base_urlObject

Get base_url value.

Falls back to the LETMEIN_BASE_URL environment variable and finally to DEFAULT_BASE_URL when nothing was explicitly configured.

Example

Eli::Config.base_url



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

def base_url
  @base_url || ENV["LETMEIN_BASE_URL"] || DEFAULT_BASE_URL
end

.base_url=(value) ⇒ Object

Set base_url value.

Example

Eli::Config.base_url = "http://localhost:4000"

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/eli/config.rb', line 16

def base_url=(value)
  raise ArgumentError, "base_url must be a string" unless value.is_a?(String)

  @base_url = value
end

.reset!Object

Resets any value set through base_url= (useful for tests).



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

def reset!
  @base_url = nil
end