Closed queirozfcom closed 9 years ago
Right now I have a problem because methods like Node#attach_edge!
are called on an actual node when a call to edge
(in the DSL) is made. I need to delay all these 'links' until after the whole diagram has been created.
Method calls in the DSL will not cause actual methods in class Diagram
to get called. These things will be saved internally and will only be available to the DSL.
At the end of the block started by diagram
, I will read all these things and call the actual methods in class Diagram
. At this point, I will be able to order the method calls so that all needed nodes and edges are created prior to being referenced.
This would, however, preclude circular references like
pool 'p1', triggers: 'p2'
pool 'p2', triggered_by: 'p3'
pool 'p3', something_something_references_pool_p1
Because the references would never be able to be realized.
(maybe not because I could create each node bare (i.e. just the object with nothing else) and then add stuff to them piecemeal.)
All this without breaking any tests :smile:
Sometimes it seems more natural to define bahaviours of nodes in relation to nodes that were not yet created. For example, situations like the following:
It's not very clear to me when this would actually raise errors (because it would depend on when methods are actually called on class
Diagram
) but it probably would eventually.Maybe I would need to defer the actual method calls until after all nodes, edges have been added.