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?, #diff, 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.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/openc3/models/script_engine_model.rb', line 60 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
24 25 26 |
# File 'lib/openc3/models/script_engine_model.rb', line 24 def filename @filename end |
Class Method Details
.all(scope: nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/openc3/models/script_engine_model.rb', line 40 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
28 29 30 |
# File 'lib/openc3/models/script_engine_model.rb', line 28 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”
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/openc3/models/script_engine_model.rb', line 49 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
32 33 34 35 36 37 38 |
# File 'lib/openc3/models/script_engine_model.rb', line 32 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
71 72 73 74 75 76 77 78 |
# File 'lib/openc3/models/script_engine_model.rb', line 71 def as_json(*a) { 'name' => @name, 'updated_at' => @updated_at, 'plugin' => @plugin, 'filename' => @filename } end |
#deploy(gem_path, variables, validate_only: false) ⇒ Object
84 85 86 |
# File 'lib/openc3/models/script_engine_model.rb', line 84 def deploy(gem_path, variables, validate_only: false) # Nothing to do end |
#handle_config(parser, keyword, parameters) ⇒ Object
80 81 82 |
# File 'lib/openc3/models/script_engine_model.rb', line 80 def handle_config(parser, keyword, parameters) raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Script Engine: #{keyword} #{parameters.join(" ")}") end |