Class: OpenC3::OfflineAccessModel

Inherits:
Model show all
Defined in:
lib/openc3/models/offline_access_model.rb

Constant Summary collapse

PRIMARY_KEY =
'openc3__offline_access'

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

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

Constructor Details

#initialize(name:, offline_access_token: nil, updated_at: nil, scope:) ⇒ OfflineAccessModel

END NOTE



42
43
44
45
# File 'lib/openc3/models/offline_access_model.rb', line 42

def initialize(name:, offline_access_token: nil, updated_at: nil, scope:)
  super("#{scope}__#{PRIMARY_KEY}", name: name, scope: scope)
  @offline_access_token = offline_access_token
end

Instance Attribute Details

#offline_access_tokenObject

Returns the value of attribute offline_access_token.



25
26
27
# File 'lib/openc3/models/offline_access_model.rb', line 25

def offline_access_token
  @offline_access_token
end

Class Method Details

.all(scope:) ⇒ Object



37
38
39
# File 'lib/openc3/models/offline_access_model.rb', line 37

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



29
30
31
# File 'lib/openc3/models/offline_access_model.rb', line 29

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

.names(scope:) ⇒ Object



33
34
35
# File 'lib/openc3/models/offline_access_model.rb', line 33

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

Instance Method Details

#as_json(*a) ⇒ Hash

Returns JSON encoding of this model.

Returns:

  • (Hash)

    JSON encoding of this model



48
49
50
51
52
53
# File 'lib/openc3/models/offline_access_model.rb', line 48

def as_json(*a)
  { 'name' => @name,
    'updated_at' => @updated_at,
    'offline_access_token' => @offline_access_token,
    'scope' => @scope }
end