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.
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.
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
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def after @after end |
#attribute ⇒ Object
Returns the value of attribute attribute
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def attribute @attribute end |
#before ⇒ Object
Returns the value of attribute before
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def before @before end |
#by_type ⇒ Object
Returns the value of attribute by_type
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def by_type @by_type end |
#id ⇒ Object
Returns the value of attribute id
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def id @id end |
#kind ⇒ Object
Returns the value of attribute kind
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def kind @kind end |
#label ⇒ Object
Returns the value of attribute label
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def label @label end |
#op ⇒ Object
Returns the value of attribute op
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def op @op end |
#owner_id ⇒ Object
Returns the value of attribute owner_id
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def owner_id @owner_id end |
#parent_id ⇒ Object
Returns the value of attribute parent_id
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def parent_id @parent_id end |
#path ⇒ Object
Returns the value of attribute path
26 27 28 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 26 def path @path end |
Instance Method Details
#description ⇒ Object
One-line human description for a changelog / ticket comment.
37 38 39 40 41 42 43 44 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 37 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
28 29 30 31 32 33 34 |
# File 'lib/ecoportal/api/graphql/diff/change.rb', line 28 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 }.compact end |