Sha256: a4c587ba8569101c381714177fd3fe2241a8a4c3bb7fbb7bd72b81bff493b9be

Contents?: true

Size: 608 Bytes

Versions: 10

Compression:

Stored size: 608 Bytes

Contents

module Exlibris
  module Aleph
    # 
    # If a class is abstract, it can't be instantiated.
    # 
    module Abstract
      def self.included(klass)
        klass.class_eval do
          extend ClassAttributes
        end
      end

      module ClassAttributes
        def abstract
          @abstract ||= false
        end
        alias :abstract? :abstract

        attr_writer :abstract
        protected :abstract=
      end

      def initialize *args
        raise NotImplementedError.new("Cannot instantiate #{self.class.name}.  It is abstract") if self.class.abstract?
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
exlibris-aleph-1.1.0 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.8 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.7 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.6 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.5 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.4 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.3 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.2 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.1 lib/exlibris/aleph/abstract.rb
exlibris-aleph-1.0.0 lib/exlibris/aleph/abstract.rb