class Dbd::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.
Public Class Methods
Builds a new ContextFact
.
@param [Hash{Symbol => Object}] options @option options [Fact::Subject] :subject (new_subject) Optional: the subject for the ContextFact
@option options [String] :predicate Required: the subject for the ContextFact
@option options [String] :object Required: the object for the ContextFact
# File lib/dbd/context_fact.rb, line 30 def initialize(options) validate_context_subject(options) super end
Public Instance Methods
Confirms this is a ContextFact
Needed for validations that depend on different behavior for a context_fact (mainly, no context_subject).
# File lib/dbd/context_fact.rb, line 50 def context_fact? true end
Validates the presence or absence of context_subject.
Here, in the derived ContextFact
, it must not be present. @param [#nil?] context_subject Return [nil, String] nil if valid, an error message if not
# 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
Private Instance Methods
# File lib/dbd/context_fact.rb, line 62 def context_subject_short "[ cont ]" end
Validate that context_subject is not set here.
# File lib/dbd/context_fact.rb, line 58 def validate_context_subject(options) raise ContextError if options[:context_subject] end