Class: Microsandbox::BackendInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/microsandbox/backend_info.rb

Overview

Secret-safe description of the active default backend, from default_backend_info (runtime v0.6.9). Describes what selected the backend and where it points — never its credential: the API key is deliberately absent.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ BackendInfo

Returns a new instance of BackendInfo.



15
16
17
18
19
20
# File 'lib/microsandbox/backend_info.rb', line 15

def initialize(data)
  @kind = data["kind"]
  @api_url = data["api_url"]
  @source = data["source"]
  @profile = data["profile"]
end

Instance Attribute Details

#api_urlString? (readonly)

Returns effective cloud API endpoint (nil for local).

Returns:

  • (String, nil)

    effective cloud API endpoint (nil for local)



10
11
12
# File 'lib/microsandbox/backend_info.rb', line 10

def api_url
  @api_url
end

#profileString? (readonly)

Returns the selected profile name, when a profile chose the backend.

Returns:

  • (String, nil)

    the selected profile name, when a profile chose the backend



13
14
15
# File 'lib/microsandbox/backend_info.rb', line 13

def profile
  @profile
end

Instance Method Details

#cloud?Boolean

Returns:

  • (Boolean)


38
# File 'lib/microsandbox/backend_info.rb', line 38

def cloud? = kind == :cloud

#inspectObject



40
41
42
43
44
# File 'lib/microsandbox/backend_info.rb', line 40

def inspect
  "#<Microsandbox::BackendInfo kind=#{@kind} source=#{@source.inspect}" \
    "#{" api_url=#{@api_url.inspect}" if @api_url}" \
    "#{" profile=#{@profile.inspect}" if @profile}>"
end

#kindSymbol

Returns :local or :cloud.

Returns:

  • (Symbol)

    :local or :cloud



23
24
25
# File 'lib/microsandbox/backend_info.rb', line 23

def kind
  @kind.to_sym
end

#local?Boolean

Returns:

  • (Boolean)


36
# File 'lib/microsandbox/backend_info.rb', line 36

def local? = kind == :local

#sourceSymbol

What selected this backend: :programmatic (an SDK setter), :MSB_BACKEND / :MSB_API_KEY / :MSB_PROFILE (environment), :profile (an explicit SDK profile constructor), :active_profile (the SDK config file), or :default (the final local fallback).

Returns:

  • (Symbol)


32
33
34
# File 'lib/microsandbox/backend_info.rb', line 32

def source
  @source.to_sym
end