Sha256: b9152dcc058724e31fb3f9a83c4116fa86035d61a228068f78f6d3e0cc60fd99

Contents?: true

Size: 506 Bytes

Versions: 8

Compression:

Stored size: 506 Bytes

Contents

module Gitrb
  class GitObject
    attr_accessor :repository, :id

    def initialize(options = {})
      @repository = options[:repository]
      @id = options[:id]
    end

    def object
      self
    end

    @types = {}

    def self.inherited(subclass)
      @types[subclass.name[7..-1].downcase] = subclass
    end

    def self.factory(type, *args)
      klass = @types[type]
      raise NotImplementedError, "Object type not supported: #{type}" if !klass
      klass.new(*args)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gitrb-0.1.6 lib/gitrb/gitobject.rb
gitrb-0.1.5 lib/gitrb/gitobject.rb
gitrb-0.1.4 lib/gitrb/gitobject.rb
gitrb-0.1.3 lib/gitrb/gitobject.rb
gitrb-0.1.2 lib/gitrb/gitobject.rb
gitrb-0.1.1 lib/gitrb/gitobject.rb
gitrb-0.1.0 lib/gitrb/gitobject.rb
gitrb-0.0.9 lib/gitrb/gitobject.rb