Class: Cosmos::MicroserviceStatusModel

Inherits:
Model show all
Defined in:
lib/cosmos/models/microservice_status_model.rb

Constant Summary collapse

PRIMARY_KEY =
'cosmos_microservice_status'

Instance Attribute Summary collapse

Attributes inherited from Model

#name, #plugin, #scope, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#as_config, #create, #deploy, #destroy, filter, find_all_by_plugin, from_json, get_all_models, get_model, handle_config, set, #undeploy, #update

Constructor Details

#initialize(name:, state: nil, count: 0, error: nil, custom: nil, updated_at: nil, plugin: nil, scope:) ⇒ MicroserviceStatusModel

Returns a new instance of MicroserviceStatusModel.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cosmos/models/microservice_status_model.rb', line 45

def initialize(
  name:,
  state: nil,
  count: 0,
  error: nil,
  custom: nil,
  updated_at: nil,
  plugin: nil,
  scope:
)
  super("#{scope}__#{PRIMARY_KEY}", name: name, updated_at: updated_at, plugin: plugin, scope: scope)
  @state = state
  @count = count
  @error = error
  @custom = custom
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



27
28
29
# File 'lib/cosmos/models/microservice_status_model.rb', line 27

def count
  @count
end

#customObject

Returns the value of attribute custom.



29
30
31
# File 'lib/cosmos/models/microservice_status_model.rb', line 29

def custom
  @custom
end

#errorObject

Returns the value of attribute error.



28
29
30
# File 'lib/cosmos/models/microservice_status_model.rb', line 28

def error
  @error
end

#stateObject

Returns the value of attribute state.



26
27
28
# File 'lib/cosmos/models/microservice_status_model.rb', line 26

def state
  @state
end

Class Method Details

.all(scope:) ⇒ Object



41
42
43
# File 'lib/cosmos/models/microservice_status_model.rb', line 41

def self.all(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

.get(name:, scope:) ⇒ Object

NOTE: The following three class methods are used by the ModelController and are reimplemented to enable various Model class methods to work



33
34
35
# File 'lib/cosmos/models/microservice_status_model.rb', line 33

def self.get(name:, scope:)
  super("#{scope}__#{PRIMARY_KEY}", name: name)
end

.names(scope:) ⇒ Object



37
38
39
# File 'lib/cosmos/models/microservice_status_model.rb', line 37

def self.names(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

Instance Method Details

#as_jsonObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cosmos/models/microservice_status_model.rb', line 62

def as_json
  {
    'name' => @name,
    'state' => @state,
    'count' => @count,
    'error' => @error.as_json,
    'custom' => @custom.as_json,
    'plugin' => @plugin,
    'updated_at' => @updated_at
  }
end