Sha256: a57502a6ba7ba0821e385d6d0252b137d968e777c7aa755e385ef60a844ca7ce

Contents?: true

Size: 790 Bytes

Versions: 11

Compression:

Stored size: 790 Bytes

Contents

require 'delorean/base'

module Delorean
  class AbstractContainer
    def initialize
      @engines = {}
    end

    def names
      @engines.keys.map {|n, v| n}
    end

    def get(name, version)
      @engines[ [name, version] ]
    end

    def add(name, version, engine)
      @engines[ [name, version] ] = engine
    end

    def import(name, version)
      engine = get(name, version)

      return engine if engine

      if names.member? name
        n, v = @engines.keys.detect {|n, v| n == name}

        raise "Can't import #{name} version #{version}. " +
          "Collides with imported version #{v}."
      end

      add(name, version, get_engine(name, version))
    end

    def get_engine(name, version)
      raise "get_engine needs to be overriden"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
delorean_lang-0.1.03 lib/delorean/container.rb
delorean_lang-0.1.02 lib/delorean/container.rb
delorean_lang-0.1.01 lib/delorean/container.rb
delorean_lang-0.1.00 lib/delorean/container.rb
delorean_lang-0.0.43 lib/delorean/container.rb
delorean_lang-0.0.42 lib/delorean/container.rb
delorean_lang-0.0.40 lib/delorean/container.rb
delorean_lang-0.0.39 lib/delorean/container.rb
delorean_lang-0.0.38 lib/delorean/container.rb
delorean_lang-0.0.34 lib/delorean/container.rb
delorean_lang-0.0.33 lib/delorean/container.rb