Class: Smith::Attribution::Context
- Inherits:
-
Data
- Object
- Data
- Smith::Attribution::Context
- Defined in:
- lib/smith/attribution.rb
Instance Attribute Summary collapse
-
#branch_key ⇒ Object
readonly
Returns the value of attribute branch_key.
-
#execution_key ⇒ Object
readonly
Returns the value of attribute execution_key.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#round ⇒ Object
readonly
Returns the value of attribute round.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#transition ⇒ Object
readonly
Returns the value of attribute transition.
-
#workflow ⇒ Object
readonly
Returns the value of attribute workflow.
Instance Method Summary collapse
-
#merge(**overrides) ⇒ Object
Overlay semantics: nil overrides are ignored so an inner scope can only add or replace attribution, never blank an outer value.
-
#override(**fields) ⇒ Object
Replacement semantics: sets the given fields verbatim, nil included, so a scope that owns a field can reset it (a step whose transition declares no
frommust not inherit an enclosing step'sfrom). - #to_fields ⇒ Object
Instance Attribute Details
#branch_key ⇒ Object (readonly)
Returns the value of attribute branch_key
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def branch_key @branch_key end |
#execution_key ⇒ Object (readonly)
Returns the value of attribute execution_key
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def execution_key @execution_key end |
#from ⇒ Object (readonly)
Returns the value of attribute from
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def from @from end |
#round ⇒ Object (readonly)
Returns the value of attribute round
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def round @round end |
#to ⇒ Object (readonly)
Returns the value of attribute to
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def to @to end |
#transition ⇒ Object (readonly)
Returns the value of attribute transition
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def transition @transition end |
#workflow ⇒ Object (readonly)
Returns the value of attribute workflow
24 25 26 |
# File 'lib/smith/attribution.rb', line 24 def workflow @workflow end |
Instance Method Details
#merge(**overrides) ⇒ Object
Overlay semantics: nil overrides are ignored so an inner scope can only add or replace attribution, never blank an outer value.
27 28 29 30 31 32 |
# File 'lib/smith/attribution.rb', line 27 def merge(**overrides) filtered = overrides.compact return self if filtered.empty? override(**filtered) end |
#override(**fields) ⇒ Object
Replacement semantics: sets the given fields verbatim, nil included,
so a scope that owns a field can reset it (a step whose transition
declares no from must not inherit an enclosing step's from).
Built on to_h, not Data#with, which requires Ruby 3.3 while the gem
supports 3.2.
39 40 41 |
# File 'lib/smith/attribution.rb', line 39 def override(**fields) self.class.new(**to_h, **fields) end |
#to_fields ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/smith/attribution.rb', line 43 def to_fields { execution_key: execution_key, transition: transition, from: from, to: to, branch_key: branch_key, round: round, workflow: workflow }.compact end |