Class: Hoss::Context Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hoss/context.rb,
lib/hoss/context/user.rb,
lib/hoss/context/request.rb,
lib/hoss/context/response.rb,
lib/hoss/context/request/url.rb,
lib/hoss/context/request/socket.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Framework, Request, Response, Service, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom: {}, labels: {}, user: nil, service: nil) ⇒ Context

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Context.



29
30
31
32
33
34
# File 'lib/hoss/context.rb', line 29

def initialize(custom: {}, labels: {}, user: nil, service: nil)
  @custom = custom
  @labels = labels
  @user = user || User.new
  @service = service
end

Instance Attribute Details

#customObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/hoss/context.rb', line 42

def custom
  @custom
end

#labelsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
# File 'lib/hoss/context.rb', line 43

def labels
  @labels
end

#requestObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/hoss/context.rb', line 39

def request
  @request
end

#responseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/hoss/context.rb', line 40

def response
  @response
end

#serviceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/hoss/context.rb', line 44

def service
  @service
end

#userObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/hoss/context.rb', line 41

def user
  @user
end

Instance Method Details

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/CyclomaticComplexity

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
# File 'lib/hoss/context.rb', line 47

def empty?
  return false if labels.any?
  return false if custom.any?
  return false if user.any?
  return false if service
  return false if request || response

  true
end

#set_service(framework_name: nil, framework_version: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:enable Metrics/CyclomaticComplexity



58
59
60
61
62
# File 'lib/hoss/context.rb', line 58

def set_service(framework_name: nil, framework_version: nil)
  @service = Service.new(
    Framework.new(framework_name, framework_version)
  )
end