Class: Misc::Script
- Inherits:
-
Object
- Object
- Misc::Script
- Includes:
- AttributesReader
- Defined in:
- lib/misc/script.rb
Overview
Script represents used-defined input that can be used to compile and execute a script from the ScriptService based on the ScriptType.
Instance Method Summary collapse
- #id_or_code_expr ⇒ String
-
#initialize(id_or_code:, params: {}, type: Enums::ScriptTypes.inline, lang: 'painless', options: {}) ⇒ Script
constructor
A new instance of Script.
- #lang_expr ⇒ String
- #options_expr ⇒ Hash
- #params_expr ⇒ Hash
-
#settings ⇒ Object
return [Hash].
- #type_expr ⇒ Enums::ScriptTypes
Methods included from AttributesReader
Constructor Details
#initialize(id_or_code:, params: {}, type: Enums::ScriptTypes.inline, lang: 'painless', options: {}) ⇒ Script
Returns a new instance of Script.
15 16 17 18 19 20 21 |
# File 'lib/misc/script.rb', line 15 def initialize(id_or_code:, params: {}, type: Enums::ScriptTypes.inline, lang: 'painless', options: {}) @id_or_code = id_or_code @params = params @type = type @lang = lang @options = end |
Instance Method Details
#id_or_code_expr ⇒ String
38 39 40 |
# File 'lib/misc/script.rb', line 38 def id_or_code_expr @id_or_code end |
#lang_expr ⇒ String
53 54 55 |
# File 'lib/misc/script.rb', line 53 def lang_expr @lang end |
#options_expr ⇒ Hash
58 59 60 |
# File 'lib/misc/script.rb', line 58 def @options end |
#params_expr ⇒ Hash
43 44 45 |
# File 'lib/misc/script.rb', line 43 def params_expr @params end |
#settings ⇒ Object
return [Hash]
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/misc/script.rb', line 24 def settings settings = {} if @type.script_type == Enums::ScriptTypes.inline.script_type settings[:source] = @id_or_code else settings[:id] = @id_or_code end settings[:lang] = @lang if @lang.present? settings[:params] = @params if @params.present? settings[:options] = @options if @options.present? settings end |
#type_expr ⇒ Enums::ScriptTypes
48 49 50 |
# File 'lib/misc/script.rb', line 48 def type_expr @type end |