Class: OpenC3::ScriptEngineModel
- Defined in:
- lib/openc3/models/script_engine_model.rb
Constant Summary collapse
- PRIMARY_KEY =
'openc3_script_engines'
Instance Attribute Summary collapse
-
#filename ⇒ Object
Script Engine filename.
Attributes inherited from Model
#name, #plugin, #scope, #updated_at
Class Method Summary collapse
- .all(scope: nil) ⇒ Object
-
.get(name:, scope: nil) ⇒ Object
NOTE: The following three class methods are used by the ModelController and are reimplemented to enable various Model class methods to work.
-
.handle_config(parser, keyword, parameters, plugin: nil, needs_dependencies: false, scope:) ⇒ Object
Called by the PluginModel to allow this class to validate it’s top-level keyword: “SCRIPT_ENGINE”.
- .names(scope: nil) ⇒ Object
Instance Method Summary collapse
- #as_json(*a) ⇒ Object
- #deploy(gem_path, variables, validate_only: false) ⇒ Object
- #handle_config(parser, keyword, parameters) ⇒ Object
-
#initialize(name:, updated_at: nil, plugin: nil, filename: nil, scope:) ⇒ ScriptEngineModel
constructor
A new instance of ScriptEngineModel.
Methods inherited from Model
#check_disable_erb, #create, #destroy, #destroyed?, filter, find_all_by_plugin, from_json, get_all_models, get_model, set, store, store_queued, #undeploy, #update
Constructor Details
#initialize(name:, updated_at: nil, plugin: nil, filename: nil, scope:) ⇒ ScriptEngineModel
Returns a new instance of ScriptEngineModel.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/openc3/models/script_engine_model.rb', line 65 def initialize( name:, updated_at: nil, plugin: nil, filename: nil, scope: ) super(PRIMARY_KEY, name: name, plugin: plugin, updated_at: updated_at, scope: scope) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object
Script Engine filename
29 30 31 |
# File 'lib/openc3/models/script_engine_model.rb', line 29 def filename @filename end |
Class Method Details
.all(scope: nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/openc3/models/script_engine_model.rb', line 45 def self.all(scope: nil) tools = Store.hgetall(PRIMARY_KEY) tools.each do |key, value| tools[key] = JSON.parse(value, :allow_nan => true, :create_additions => true) end return tools end |
.get(name:, scope: nil) ⇒ 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/openc3/models/script_engine_model.rb', line 33 def self.get(name:, scope: nil) super(PRIMARY_KEY, name: name) end |
.handle_config(parser, keyword, parameters, plugin: nil, needs_dependencies: false, scope:) ⇒ Object
Called by the PluginModel to allow this class to validate it’s top-level keyword: “SCRIPT_ENGINE”
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/openc3/models/script_engine_model.rb', line 54 def self.handle_config(parser, keyword, parameters, plugin: nil, needs_dependencies: false, scope:) case keyword when 'SCRIPT_ENGINE' parser.verify_num_parameters(1, 3, "SCRIPT_ENGINE <Extension> <Filename>") return self.new(name: parameters[0], plugin: plugin, filename: parameters[1], scope: scope) else raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Script Engine: #{keyword} #{parameters.join(" ")}") end return nil end |
.names(scope: nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/openc3/models/script_engine_model.rb', line 37 def self.names(scope: nil) array = [] all(scope: scope).each do |name, _script_engine| array << name end array end |
Instance Method Details
#as_json(*a) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/openc3/models/script_engine_model.rb', line 76 def as_json(*a) { 'name' => @name, 'updated_at' => @updated_at, 'plugin' => @plugin, 'filename' => @filename } end |
#deploy(gem_path, variables, validate_only: false) ⇒ Object
89 90 91 |
# File 'lib/openc3/models/script_engine_model.rb', line 89 def deploy(gem_path, variables, validate_only: false) # Nothing to do end |
#handle_config(parser, keyword, parameters) ⇒ Object
85 86 87 |
# File 'lib/openc3/models/script_engine_model.rb', line 85 def handle_config(parser, keyword, parameters) raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Script Engine: #{keyword} #{parameters.join(" ")}") end |