Class: Hecks::StateRef
- Inherits:
-
Struct
- Object
- Struct
- Hecks::StateRef
- Defined in:
- lib/hecks/literal.rb
Overview
THE ONE SPELLING FOR A CAPTURED RUBY LITERAL ON THE WIRE.
Several to_h fields hold a value the author wrote in a bluebook —
where(status: { eq: "open" }), then_set append: { direction: { value: "credit" } }, dispatch ... with: { number: :source }, an attribute's
default: — as TEXT, because the export has to stand on its own and a
String field cannot say "this one was a Symbol". Every such field is the
same question and now gets the same answer.
It was three answers before, and they disagreed on both axes that matter.
Mutation#appended_fields spelled a Symbol BARE and everything else
inspect; QuerySpecification.render_value spelled a Symbol with a COLON
and everything else to_s. So :amount crossed as "amount" in a mutation
and ":amount" in a saga binding — the same value, two spellings, and each
reader had to know which field it was looking at. Worse, to_s/inspect
on a Hash is Ruby's OWN rendering, which moved under us: 3.3 writes
{:value=>"credit"} and 3.4 writes {value: "credit"} for the identical
Hash, so the wire format was silently pinned to an interpreter version.
SELF-DESCRIBING IS THE RULE, stated once here rather than inherited from
whatever inspect happens to do: a symbol wears its colon, a string wears
its quotes, a hash wears {key: value} braces, a list wears its brackets,
and a number, a boolean and nil are bare. read is the exact inverse, and
is the only thing that should ever take one of these strings apart.
A MUTATION SOURCE THAT READS THE RECORD'S OWN STATE — sets :positions, append: { knights: state(:knights) }. A bare Symbol in a mutation
source always names a command ARGUMENT (and imports it as one when
the target's own field carries the same name — CommandBuilder #resolve_append_fields!); before this there was no way to say "the
value this field already holds", so a command could not snapshot its
own record — chess's threefold repetition needs exactly that, a
position copied off the board every ply. Spelled state(:name) on
the wire, read back by Literal.read; classified kind: "state" in
a set's own source (Behaviour::Mutation#classified_source).
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
36 37 38 |
# File 'lib/hecks/literal.rb', line 36 def name @name end |
Instance Method Details
#to_s ⇒ Object
37 |
# File 'lib/hecks/literal.rb', line 37 def to_s = "state(:#{name})" |