Class: Ecoportal::API::GraphQL::Model::Template::Force
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Model::Template::Force
- Includes:
- Node
- Defined in:
- lib/ecoportal/api/graphql/model/template/force.rb
Overview
One force, owned by a Stage (18_template_editor_save_path.md section A.1:
TemplateStageFields.forces). Editing an existing force is limited to
name/custom_script/url/content_b64 (editForce's own argument list,
input/workflow_command/edit_force.rb) — weight/lastSyncedAt are
server-managed and not exposed as writable attributes here.
Constant Summary collapse
- PLACEHOLDER_PREFIX =
'frc'.freeze
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
-
#content_b64 ⇒ Object
Returns the value of attribute content_b64.
-
#custom_script ⇒ Object
Returns the value of attribute custom_script.
-
#helpers ⇒ Object
readonly
Returns the value of attribute helpers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes included from Node
Instance Method Summary collapse
- #add_binding(reference_id:, name: nil, type: Binding::BINDING_TYPE) ⇒ Object
- #add_helper(name: nil, file_path: nil, script: nil, content_b64: nil) ⇒ Object
- #changed_attributes ⇒ Object
- #dirty? ⇒ Boolean
-
#initialize(template:, stage:, id: nil, name: nil, custom_script: nil, url: nil, content_b64: nil) ⇒ Force
constructor
A new instance of Force.
Methods included from Node
#new?, #placeholder, #ref, #remove!, #removed?, #resolve!
Constructor Details
#initialize(template:, stage:, id: nil, name: nil, custom_script: nil, url: nil, content_b64: nil) ⇒ Force
Returns a new instance of Force.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 19 def initialize(template:, stage:, id: nil, name: nil, custom_script: nil, url: nil, content_b64: nil) @template = template @stage = stage @id = id @name = name @custom_script = custom_script @url = url @content_b64 = content_b64 # rubocop:disable Naming/VariableNumber @bindings = [] @helpers = [] @snapshot = snapshot_attrs.freeze end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
16 17 18 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 16 def bindings @bindings end |
#content_b64 ⇒ Object
Returns the value of attribute content_b64.
17 18 19 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 17 def content_b64 @content_b64 end |
#custom_script ⇒ Object
Returns the value of attribute custom_script.
17 18 19 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 17 def custom_script @custom_script end |
#helpers ⇒ Object (readonly)
Returns the value of attribute helpers.
16 17 18 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 16 def helpers @helpers end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 17 def name @name end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
16 17 18 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 16 def stage @stage end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
16 17 18 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 16 def template @template end |
#url ⇒ Object
Returns the value of attribute url.
17 18 19 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 17 def url @url end |
Instance Method Details
#add_binding(reference_id:, name: nil, type: Binding::BINDING_TYPE) ⇒ Object
32 33 34 35 36 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 32 def add_binding(reference_id:, name: nil, type: Binding::BINDING_TYPE) binding = Binding.new(template: template, force: self, name: name, reference_id: reference_id, type: type) bindings << binding binding end |
#add_helper(name: nil, file_path: nil, script: nil, content_b64: nil) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 38 def add_helper(name: nil, file_path: nil, script: nil, content_b64: nil) helper = Helper.new(template: template, force: self, name: name, file_path: file_path, script: script, content_b64: content_b64) helpers << helper helper end |
#changed_attributes ⇒ Object
49 50 51 52 53 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 49 def changed_attributes return {} if new? || removed? snapshot_attrs.each_with_object({}) { |(k, v), h| h[k] = v if v != @snapshot[k] } end |
#dirty? ⇒ Boolean
45 46 47 |
# File 'lib/ecoportal/api/graphql/model/template/force.rb', line 45 def dirty? !removed? && !new? && snapshot_attrs != @snapshot end |