Class: Rigor::FlowContribution::Fact

Inherits:
Data
  • Object
show all
Defined in:
lib/rigor/flow_contribution/fact.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_kind:, target_name:, type:, negative: false) ⇒ Fact

Returns a new instance of Fact.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rigor/flow_contribution/fact.rb', line 59

def initialize(target_kind:, target_name:, type:, negative: false)
  unless FACT_VALID_TARGET_KINDS.include?(target_kind)
    raise ArgumentError,
          "FlowContribution::Fact target_kind must be one of " \
          "#{FACT_VALID_TARGET_KINDS.inspect}, got #{target_kind.inspect}"
  end

  unless target_name.is_a?(Symbol)
    raise ArgumentError,
          "FlowContribution::Fact target_name must be a Symbol, got #{target_name.inspect}"
  end

  super
end

Instance Attribute Details

#negativeObject (readonly)

Returns the value of attribute negative

Returns:

  • (Object)

    the current value of negative



58
59
60
# File 'lib/rigor/flow_contribution/fact.rb', line 58

def negative
  @negative
end

#target_kindObject (readonly)

Returns the value of attribute target_kind

Returns:

  • (Object)

    the current value of target_kind



58
59
60
# File 'lib/rigor/flow_contribution/fact.rb', line 58

def target_kind
  @target_kind
end

#target_nameObject (readonly)

Returns the value of attribute target_name

Returns:

  • (Object)

    the current value of target_name



58
59
60
# File 'lib/rigor/flow_contribution/fact.rb', line 58

def target_name
  @target_name
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



58
59
60
# File 'lib/rigor/flow_contribution/fact.rb', line 58

def type
  @type
end

Instance Method Details

#negative?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/rigor/flow_contribution/fact.rb', line 83

def negative?
  negative == true
end

#targetObject

Composite target identifier the merger keys on. ‘:self` for self-targeted facts; otherwise `[:parameter, name]` so two contributions that narrow the same parameter (regardless of source family) land in the same merge bucket.



79
80
81
# File 'lib/rigor/flow_contribution/fact.rb', line 79

def target
  target_kind == :self ? :self : [target_kind, target_name]
end