Class: Cosmos::ProcessStatusModel

Inherits:
EphemeralModel show all
Defined in:
lib/cosmos/models/process_status_model.rb

Overview

Stores the status about an process.

Constant Summary collapse

PRIMARY_KEY =
'cosmos_process_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 EphemeralModel

store

Methods inherited from Model

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

Constructor Details

#initialize(name:, state: nil, process_type: nil, detail: nil, output: nil, updated_at: nil, plugin: nil, scope:) ⇒ ProcessStatusModel

END NOTE



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

def initialize(
  name:,
  state: nil,
  process_type: nil,
  detail: nil,
  output: nil,
  updated_at: nil,
  plugin: nil,
  scope:
)
  super("#{scope}__#{PRIMARY_KEY}", name: name, updated_at: updated_at, plugin: plugin, scope: scope)
  @state = state
  @process_type = process_type
  @detail = detail
  @output = output
end

Instance Attribute Details

#detailObject

Returns the value of attribute detail.



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

def detail
  @detail
end

#outputObject

Returns the value of attribute output.



30
31
32
# File 'lib/cosmos/models/process_status_model.rb', line 30

def output
  @output
end

#process_typeObject

Returns the value of attribute process_type.



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

def process_type
  @process_type
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

Class Method Details

.all(scope:) ⇒ Object



42
43
44
# File 'lib/cosmos/models/process_status_model.rb', line 42

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



34
35
36
# File 'lib/cosmos/models/process_status_model.rb', line 34

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

.names(scope:) ⇒ Object



38
39
40
# File 'lib/cosmos/models/process_status_model.rb', line 38

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

Instance Method Details

#as_jsonObject



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/cosmos/models/process_status_model.rb', line 64

def as_json
  {
    'name' => @name,
    'state' => @state,
    'process_type' => @process_type,
    'detail' => @detail,
    'output' => @output,
    'plugin' => @plugin,
    'updated_at' => @updated_at
  }
end