Class: Rigor::FlowContribution::Fact
- Inherits:
-
Object
- Object
- Rigor::FlowContribution::Fact
- Defined in:
- lib/rigor/flow_contribution/fact.rb
Instance Method Summary collapse
-
#initialize(target_kind:, target_name:, type:, negative: false) ⇒ Fact
constructor
A new instance of Fact.
- #negative? ⇒ Boolean
-
#target ⇒ Object
Composite target identifier the merger keys on.
Constructor Details
#initialize(target_kind:, target_name:, type:, negative: false) ⇒ Fact
Returns a new instance of Fact.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rigor/flow_contribution/fact.rb', line 45 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 Method Details
#negative? ⇒ Boolean
69 70 71 |
# File 'lib/rigor/flow_contribution/fact.rb', line 69 def negative? negative == true end |
#target ⇒ Object
Composite target identifier the merger keys on. :self for self-targeted facts; otherwise
[kind, name] so two contributions that narrow the same (kind, name) pair — regardless of source
family — land in the same merge bucket. :local and :parameter facts that name the same symbol stay
in separate buckets, which is the correct semantics: a :local fact narrows the surrounding scope's
named local, a :parameter fact narrows the call-site argument matching the parameter declaration.
65 66 67 |
# File 'lib/rigor/flow_contribution/fact.rb', line 65 def target target_kind == :self ? :self : [target_kind, target_name] end |