Class: Coat::Mend
- Inherits:
-
Struct
- Object
- Struct
- Coat::Mend
- Defined in:
- lib/coat/seam.rb
Overview
A person's word that a seam is settled. coat can see that two agents laid patches over the same ground; it cannot see which one was right. Only a human closes that, so mending is the one thing in the ledger a person does rather than a tool.
Instance Attribute Summary collapse
-
#by ⇒ Object
Returns the value of attribute by.
-
#note ⇒ Object
Returns the value of attribute note.
-
#path ⇒ Object
Returns the value of attribute path.
-
#ts ⇒ Object
Returns the value of attribute ts.
Class Method Summary collapse
-
.all(entries) ⇒ Object
Keyed by path, latest word winning: mending the same seam twice is a correction, not a second seam.
-
.entry(path:, by:, note:, at: Time.now) ⇒ Object
The ledger line for a mend.
- .from(entry) ⇒ Object
Instance Attribute Details
#by ⇒ Object
Returns the value of attribute by
10 11 12 |
# File 'lib/coat/seam.rb', line 10 def by @by end |
#note ⇒ Object
Returns the value of attribute note
10 11 12 |
# File 'lib/coat/seam.rb', line 10 def note @note end |
#path ⇒ Object
Returns the value of attribute path
10 11 12 |
# File 'lib/coat/seam.rb', line 10 def path @path end |
#ts ⇒ Object
Returns the value of attribute ts
10 11 12 |
# File 'lib/coat/seam.rb', line 10 def ts @ts end |
Class Method Details
.all(entries) ⇒ Object
Keyed by path, latest word winning: mending the same seam twice is a correction, not a second seam.
17 18 19 20 |
# File 'lib/coat/seam.rb', line 17 def self.all(entries) entries.select { |entry| entry["event"] == MEND_EVENT } .to_h { |entry| [entry["path"], from(entry)] } end |
.entry(path:, by:, note:, at: Time.now) ⇒ Object
The ledger line for a mend. Written here so the one place that knows what a mend looks like is the thing that reads them back.
24 25 26 27 28 29 |
# File 'lib/coat/seam.rb', line 24 def self.entry(path:, by:, note:, at: Time.now) { "ts" => at.getutc.strftime("%Y-%m-%dT%H:%M:%SZ"), "event" => MEND_EVENT, "path" => path, "by" => by, "note" => note } end |
.from(entry) ⇒ Object
11 12 13 |
# File 'lib/coat/seam.rb', line 11 def self.from(entry) new(**entry.slice(*members.map(&:to_s)).transform_keys(&:to_sym)) end |