lib/y_petri/simulation/dependency.rb in y_petri-2.3.3 vs lib/y_petri/simulation/dependency.rb in y_petri-2.3.4
- old
+ new
@@ -1,11 +1,12 @@
# encoding: utf-8
-# Place / transition collection mixin for parametrized classes of
-# YPetri::Simulation. Expects the includer to provide +#simulation+
-# method returning current +Simulation+ instance.
-#
+# Mixin providing collections of places / transitions to classes parametrized
+# by an instance of YPetri::Simulation. Expects the includer classes to provide
+# +#simulation+ method returning the +Simulation+ instance with which they are
+# parametrized.
+#
class YPetri::Simulation
module Dependency
delegate :Place,
:Transition,
:MarkingClamp,
@@ -23,20 +24,21 @@
:A_tt,
:f2a, :c2a,
:m_vector,
:recorder,
to: :simulation
-
- # Delegates to the protected (and private) methods of simulation.
+
+ # Delegates supplied method symbols to the protected (and private) methods
+ # of the simulation.
#
- def self.delegate_to_simulation! *symbols
- symbols.each do |sym|
+ def self.delegate_to_simulation! *method_symbols
+ method_symbols.each do |symbol|
module_exec do
- define_method sym do |*aa, &b| simulation.send sym, *aa, &b end
+ define_method symbol do |*aa, &b| simulation.send symbol, *aa, &b end
end
end
end
-
+
# Necessary to overcoming the protected character of the listed methods.
#
[ :node,
:place,
:transition