Class: Smith::Attribution::Context

Inherits:
Data
  • Object
show all
Defined in:
lib/smith/attribution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#branch_keyObject (readonly)

Returns the value of attribute branch_key

Returns:

  • (Object)

    the current value of branch_key



24
25
26
# File 'lib/smith/attribution.rb', line 24

def branch_key
  @branch_key
end

#execution_keyObject (readonly)

Returns the value of attribute execution_key

Returns:

  • (Object)

    the current value of execution_key



24
25
26
# File 'lib/smith/attribution.rb', line 24

def execution_key
  @execution_key
end

#fromObject (readonly)

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



24
25
26
# File 'lib/smith/attribution.rb', line 24

def from
  @from
end

#roundObject (readonly)

Returns the value of attribute round

Returns:

  • (Object)

    the current value of round



24
25
26
# File 'lib/smith/attribution.rb', line 24

def round
  @round
end

#toObject (readonly)

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



24
25
26
# File 'lib/smith/attribution.rb', line 24

def to
  @to
end

#transitionObject (readonly)

Returns the value of attribute transition

Returns:

  • (Object)

    the current value of transition



24
25
26
# File 'lib/smith/attribution.rb', line 24

def transition
  @transition
end

#workflowObject (readonly)

Returns the value of attribute workflow

Returns:

  • (Object)

    the current value of 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_fieldsObject



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