Class: Ecoportal::API::GraphQL::Diff::Change
- Inherits:
-
Struct
- Object
- Struct
- Ecoportal::API::GraphQL::Diff::Change
- Defined in:
- lib/ecoportal/api/graphql/diff/change.rb
Overview
One structural change between two snapshots of the same page/template.
Deliberately command-ready: op + kind + id + before/after is enough for a later pass to synthesise the matching WorkflowCommand (editStage / addField / removeField / editFieldConfiguration / addSelectFieldOption / …) — the "portable commit".
op: :added | :removed | :changed | :moved kind: :stage | :section | :field | :option | :field_config | :gauge_stop
parent_id: id of the owning entity when the change is nested and the child id alone is not enough to address a command. Set for :option changes (the parent data field id) so a synthesiser can emit add/edit/removeSelectFieldOption without re-deriving it; also for :field_config (the data field id) and :gauge_stop (the gauge field id).
by_type: for :field_config changes, the byType sub-hash key (e.g. :gauge, :select, :date)
under which the typed editFieldConfiguration property is nested. nil for other kinds.
owner_id: the id of the GRANDPARENT node, when a create needs a second structural back-ref that parent_id alone cannot carry. Set for an ADDED :field (parent_id = its section id, owner_id = its stage id) because addField requires BOTH sectionId and stageId (both NON_NULL in the schema). nil for every other kind/op.
value: for an ADDED :option, the select option's value (the schema's addSelectFieldOption
requires it — see AddSelectFieldOptionInput, backend authority). Read from the source doc's
option.value (VersionDiff#index_options); nil when the source doc did not carry one. NEVER
defaulted to label/weight by the synthesiser — see CommandSynthesizer#option_command.
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#before ⇒ Object
Returns the value of attribute before.
-
#by_type ⇒ Object
Returns the value of attribute by_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#label ⇒ Object
Returns the value of attribute label.
-
#op ⇒ Object
Returns the value of attribute op.
-
#owner_id ⇒ Object
Returns the value of attribute owner_id.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#path ⇒ Object
Returns the value of attribute path.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#description ⇒ Object
One-line human description for a changelog / ticket comment.
- #to_h ⇒ Object
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def after @after end |
#attribute ⇒ Object
Returns the value of attribute attribute
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def attribute @attribute end |
#before ⇒ Object
Returns the value of attribute before
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def before @before end |
#by_type ⇒ Object
Returns the value of attribute by_type
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def by_type @by_type end |
#id ⇒ Object
Returns the value of attribute id
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def id @id end |
#kind ⇒ Object
Returns the value of attribute kind
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def kind @kind end |
#label ⇒ Object
Returns the value of attribute label
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def label @label end |
#op ⇒ Object
Returns the value of attribute op
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def op @op end |
#owner_id ⇒ Object
Returns the value of attribute owner_id
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def owner_id @owner_id end |
#parent_id ⇒ Object
Returns the value of attribute parent_id
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def parent_id @parent_id end |
#path ⇒ Object
Returns the value of attribute path
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def path @path end |
#value ⇒ Object
Returns the value of attribute value
31 32 33 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 31 def value @value end |
Instance Method Details
#description ⇒ Object
One-line human description for a changelog / ticket comment.
42 43 44 45 46 47 48 49 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 42 def description case op when :added then "+ #{kind} '#{label}' added#{at_path}" when :removed then "- #{kind} '#{label}' removed#{at_path}" when :changed then "~ #{kind} '#{label}' #{attribute}: #{fmt(before)} -> #{fmt(after)}#{at_path}" when :moved then "> #{kind} '#{label}' moved: #{fmt(before)} -> #{fmt(after)}" end end |
#to_h ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 33 def to_h { op: op, kind: kind, id: id, label: label, path: path, attribute: attribute, before: before, after: after, parent_id: parent_id, by_type: by_type, owner_id: owner_id, value: value }.compact end |