Sha256: 9067a058cd165846ddc2429f8f67cc368d2e778d54931db1bc0f1984596537c1

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 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!
      klass.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

1 entries across 1 versions & 1 rubygems

Version Path
y_petri-2.0.15 lib/y_petri/workspace/parametrized_subclassing.rb