Class: Dbd::Context

Inherits:
Resource show all
Defined in:
lib/dbd/context.rb

Overview

A Context is derived from a Resource, and is the set of all ContextFacts that share the same subject.

It is pointed to by a context_subject of a Fact and has no context_subject itself (the context_subject relationship from Fact to ContextFact is not recursive).

Instance Attribute Summary

Attributes inherited from Resource

#subject

Instance Method Summary collapse

Methods inherited from Resource

new_subject

Methods included from Helpers::OrderedSetCollection

add_and_return_index, #each, #freeze, #last, #size

Constructor Details

#initialize(options = {}) ⇒ Context

Build a new Context.

The subject can be either given as an argument or a new (random) subject is automatically set (see Resource for details).

A context_subject may not be given here.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :subject (Fact::Subject) — default: new_subject

    Optional: the subject for the resource



19
20
21
# File 'lib/dbd/context.rb', line 19

def initialize(options = {})
  super
end

Instance Method Details

#<<(context_fact_collection) ⇒ Context

Add a ContextFact (strictly only a ContextFact) or recursive collection of ContextFacts

Side effect on the context_fact argument:

  • if it has no subject, the subject is set in the context_fact

  • if is has the same subject as the resource, added unchanged.

  • if it has a different subject, a SubjectError is raised.

NOTE: this implementation is really only here for the documentation

Parameters:

  • context_fact_collection (ContextFact, #each)

    a recursive collection of ContextFacts

Returns:



35
36
37
# File 'lib/dbd/context.rb', line 35

def <<(context_fact_collection)
  super
end