Class: Dbd::ContextFact
Overview
ContextFact
ContextFact is derived from Fact and behaves very similar.
The ContextFacts with same subject form a Context and this is used as the target for the context_subject of a Fact.
The context_subject of a ContextFact itself is empty, so the usage of context_subject is not recursive on this level (this allows efficient single pass loading in an underlying database).
In the serialisation of a fact stream, the presence or absence of a context_subject marks the difference between a Fact and a ContextFact.
The predicates of the ContextFacts in a Context would typically come from a defined context ontology (including provenance). Experimental examples of ontologies are built in the dbd_onto project.
Instance Method Summary collapse
-
#context_fact? ⇒ Boolean
Confirms this is a ContextFact.
-
#context_subject_error(context_subject) ⇒ Object
Validates the presence or absence of context_subject.
-
#initialize(options) ⇒ ContextFact
constructor
Builds a new ContextFact.
Methods inherited from Fact
attributes, #context_subject=, #equivalent?, #errors, factory, #short, #string_values, #subject=, #time_stamp=, #values
Constructor Details
#initialize(options) ⇒ ContextFact
Builds a new ContextFact.
30 31 32 33 |
# File 'lib/dbd/context_fact.rb', line 30 def initialize() validate_context_subject() super end |
Instance Method Details
#context_fact? ⇒ Boolean
Confirms this is a ContextFact
Needed for validations that depend on different behavior for a context_fact (mainly, no context_subject).
50 51 52 |
# File 'lib/dbd/context_fact.rb', line 50 def context_fact? true end |
#context_subject_error(context_subject) ⇒ Object
Validates the presence or absence of context_subject.
Here, in the derived ContextFact, it must not be present. Return [nil, String] nil if valid, an error message if not
41 42 43 |
# File 'lib/dbd/context_fact.rb', line 41 def context_subject_error(context_subject) "ContextFact subject should not be present in ContextFact" if context_subject end |