Class: JayAPI::Elasticsearch::Script
- Inherits:
-
Object
- Object
- JayAPI::Elasticsearch::Script
- Defined in:
- lib/jay_api/elasticsearch/script.rb
Overview
Represents a scripted element in Elasticsearch. This scripted element can be used in different places. It can be used in a query clause, but can also be used to create custom aggregations or when updating documents.
Instance Attribute Summary collapse
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source:, lang: 'painless', params: nil) ⇒ Script
constructor
A new instance of Script.
-
#to_h ⇒ Hash
The hash representation of the scripted element.
Constructor Details
#initialize(source:, lang: 'painless', params: nil) ⇒ Script
Returns a new instance of Script.
15 16 17 18 19 20 21 22 |
# File 'lib/jay_api/elasticsearch/script.rb', line 15 def initialize(source:, lang: 'painless', params: nil) @source = source @lang = lang # Keeps the parameters from being modified from the outside after the # class has been initialized. @params = params.dup.freeze end |
Instance Attribute Details
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
9 10 11 |
# File 'lib/jay_api/elasticsearch/script.rb', line 9 def lang @lang end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/jay_api/elasticsearch/script.rb', line 9 def params @params end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
9 10 11 |
# File 'lib/jay_api/elasticsearch/script.rb', line 9 def source @source end |
Instance Method Details
#to_h ⇒ Hash
Returns The hash representation of the scripted element.
25 26 27 28 29 30 31 |
# File 'lib/jay_api/elasticsearch/script.rb', line 25 def to_h { source: source, lang: lang, params: params }.compact end |