Module: MrMurano::SolutionId

Included in:
Content::Base, Gateway::GweBase, SolutionBase, Webservice::WebserviceBase
Defined in:
lib/MrMurano/SolutionId.rb

Constant Summary collapse

INVALID_API_ID =
'-1'
UNEXPECTED_TYPE_OR_ERROR_MSG =
(
  'Unexpected result type or error: assuming empty instead'
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_idObject

Returns the value of attribute api_id.



17
18
19
# File 'lib/MrMurano/SolutionId.rb', line 17

def api_id
  @api_id
end

#sidObject (readonly)

Returns the value of attribute sid.



19
20
21
# File 'lib/MrMurano/SolutionId.rb', line 19

def sid
  @sid
end

#valid_api_idObject (readonly)

Returns the value of attribute valid_api_id.



18
19
20
# File 'lib/MrMurano/SolutionId.rb', line 18

def valid_api_id
  @valid_api_id
end

Instance Method Details

#affirm_validObject



59
60
61
# File 'lib/MrMurano/SolutionId.rb', line 59

def affirm_valid
  @valid_api_id = true
end

#api_id?Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/MrMurano/SolutionId.rb', line 42

def api_id?
  # The @api_id should never be nil or empty, but let's at least check.
  @api_id != INVALID_API_ID && !@api_id.to_s.empty?
end

#endpoint(_path = '') ⇒ Object



67
68
69
70
71
72
# File 'lib/MrMurano/SolutionId.rb', line 67

def endpoint(_path='')
  # This is hopefully just a DEV error, and not something user will ever see!
  return unless @uriparts[@uriparts_apidex] == INVALID_API_ID
  error("Solution ID missing! Invalid #{MrMurano::Verbose.fancy_ticks(@solntype)}")
  exit 2
end

#init_api_id!(api_id = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/MrMurano/SolutionId.rb', line 21

def init_api_id!(api_id=nil)
  @valid_api_id = false
  unless defined?(@solntype) && @solntype
    # Note that 'solution.id' isn't an actual config setting;
    # see instead 'application.id' and 'product.id'. We just
    # use 'solution.id' to indicate that the caller specified
    # a solution ID explicitly (i.e., it's not from the $cfg).
    warn 'Missing api_id or class @solntype!?' if api_id.to_s.empty?
    @solntype = 'solution.id'
  end
  if api_id
    self.api_id = api_id
  else
    # Get the application.id or product.id.
    self.api_id = $cfg[@solntype]
  end
  # Maybe raise 'No application!' or 'No product!'.
  return unless @api_id.to_s.empty?
  raise MrMurano::ConfigError.new("No #{/(.*).id/.match(@solntype)[1]} ID!")
end

#valid_api_id?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/MrMurano/SolutionId.rb', line 63

def valid_api_id?
  @valid_api_id
end