Class RGen::Fragment::FragmentedModel
In: lib/rgen/fragment/fragmented_model.rb
Parent: Object

A FragmentedModel represents a model which consists of fragments (ModelFragment).

The main purpose of this class is to resolve references across fragments and to keep the references consistent while fragments are added or removed. This way it also plays an important role in keeping the model fragments consistent and thus ModelFragment objects should only be accessed via this interface. Overall unresolved references after the resolution step are also maintained.

A FragmentedModel can also keep an RGen::Environment object up to date while fragments are added or removed. The environment must be registered with the constructor.

Reference resolution is based on arbitrary identifiers. The identifiers must be provided in the fragments’ indices. The FragmentedModel takes care to maintain the overall index.

Methods

Attributes

environment  [R] 
fragments  [R] 

Public Class methods

Creates a fragmented model. Options:

 :env
   environment which will be updated as model elements are added and removed

Public Instance methods

Add a fragment.

Adds a proc which is called when a fragment is added or removed The proc receives the fragment and one of :added, :removed

Returns the overall index. This is a Hash mapping identifiers to model elements accessible via the identifier.

Removes the fragment. The fragment will be unresolved using unresolve_fragment.

Resolve references between fragments. It is assumed that references within fragments have already been resolved. This method can be called several times. It will update the overall unresolved references.

Options:

 :fragment_provider:
   Only if a +fragment_provider+ is given, the resolve step can be reverted later on
   by a call to unresolve_fragment. The fragment provider is a proc which receives a model
   element and must return the fragment in which the element is contained.

 :use_target_type:
   reference resolver uses the expected target type to narrow the set of possible targets

Remove all references between this fragment and all other fragments. The references will be replaced with unresolved references (MMProxy objects).

Returns the overall unresolved references.

[Validate]