lib/y_petri/world/dependency.rb in y_petri-2.1.3 vs lib/y_petri/world/dependency.rb in y_petri-2.1.6
- old
+ new
@@ -1,40 +1,42 @@
#encoding: utf-8
# Provides basic skeleton for dependency injection for the triples of the
# parametrized subclasses of Place, Transition and Net in different workspaces.
#
-module YPetri::World::Dependency
- delegate :Place, :Transition, :Net, to: :world
+class YPetri::World
+ module Dependency
+ delegate :Place, :Transition, :Net, to: :world
- # Place instance identification.
- #
- def place id
- world.place( id )
- end
+ # Place instance identification.
+ #
+ def place id
+ world.place( id )
+ end
- # Transition instance identification.
- #
- def transition id
- world.transition( id )
- end
+ # Transition instance identification.
+ #
+ def transition id
+ world.transition( id )
+ end
- # Element instance identification.
- #
- def element id
- begin
- place( id )
- rescue NameError, TypeError
+ # Element instance identification.
+ #
+ def element id
begin
- transition( id )
- rescue NameError, TypeError => err
- raise TypeError, "Unrecognized place or transition: #{element} (#{err})"
+ place( id )
+ rescue NameError, TypeError
+ begin
+ transition( id )
+ rescue NameError, TypeError => err
+ raise TypeError, "Unrecognized place or transition: #{element} (#{err})"
+ end
end
end
- end
- # Net instance identification.
- #
- def net id
- Net().instance( id )
- end
-end # module YPetri::DependencyInjection
+ # Net instance identification.
+ #
+ def net id
+ Net().instance( id )
+ end
+ end # module Dependency
+end # module YPetri::World