Sha256: 50dc4fba347d942f7449121c10597a8824067256d37839fccae40d1c8995d609

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

module YPetri::Workspace::ParametrizedSubclassing
  def initialize
    # Parametrized subclasses of Place, Transition and Net.
    @Place = place_subclass = Class.new( YPetri::Place )
    @Transition = transition_subclass = Class.new YPetri::Transition
    @Net = net_subclass = Class.new YPetri::Net

    # Make them namespaces and inject dependencies:
    [ @Place, @Transition, @Net ].each do |klass|
      klass.namespace!.class_exec do # make'em work together
        define_method :Place do place_subclass end
        define_method :Transition do transition_subclass end
        define_method :Net do net_subclass end
        private :Place, :Transition, :Net # Redeclare private after redef???
      end
    end

    super # param. subclassing achieved, proceed ahead normally
  end # def initialize
end # module YPetri::Workspace::ParametrizedSubclassing

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
y_petri-2.0.14.p1 lib/y_petri/workspace/parametrized_subclassing.rb
y_petri-2.0.14 lib/y_petri/workspace/parametrized_subclassing.rb
y_petri-2.0.7 lib/y_petri/workspace/parametrized_subclassing.rb