Class: OpenReceive::Server::Config

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env: ENV) ⇒ Config

Returns a new instance of Config.



14
15
16
17
18
# File 'lib/openreceive/server/config.rb', line 14

def initialize(env: ENV)
  @nwc = clean(env["NWC_URI"])
  @lsc_connections = OpenReceive::Server::LscUri.read_environment(env)
  freeze
end

Instance Attribute Details

#lsc_connectionsObject (readonly)

Returns the value of attribute lsc_connections.



8
9
10
# File 'lib/openreceive/server/config.rb', line 8

def lsc_connections
  @lsc_connections
end

#nwcObject (readonly)

Returns the value of attribute nwc.



8
9
10
# File 'lib/openreceive/server/config.rb', line 8

def nwc
  @nwc
end

Class Method Details

.load(env: ENV) ⇒ Object



10
11
12
# File 'lib/openreceive/server/config.rb', line 10

def self.load(env: ENV)
  new(env: env)
end

Instance Method Details

#inspectObject



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

def inspect
  "#<OpenReceive::Server::Config storage=none nwc=#{@nwc.nil? ? 'missing' : '[REDACTED]'}>"
end

#swap_providers(http: nil, now: nil) ⇒ Object

FixedFloat-compatible providers for the parsed LSC connections, in env order (primary first, backup second) — the same providers the Service auto-builds when constructed without swap_providers.



23
24
25
# File 'lib/openreceive/server/config.rb', line 23

def swap_providers(http: nil, now: nil)
  OpenReceive::Server::Swap.providers_from_connections(@lsc_connections, http: http, now: now)
end

#to_hObject



27
28
29
30
31
32
# File 'lib/openreceive/server/config.rb', line 27

def to_h
  {
    "NWC_URI" => @nwc.nil? ? nil : "[REDACTED]",
    "LSC_URI_connections" => @lsc_connections.length
  }
end