abstract_type

Module to declare abstract classes and methods

MIT License

Downloads
25.9M
Stars
57
Committers
6

abstract_type

This is a small standalone gem featuring a module ripped out from axiom. It allows to declare abstract_type classes and modules in an unobstrusive way.

Examples

class Foo
  include AbstractType

  # Declare abstract instance method
  abstract_method :bar

  # Declare abstract singleton method
  abstract_singleton_method :baz
end

Foo.new  # raises NotImplementedError: Foo is an abstract type
Foo.baz  # raises NotImplementedError: Foo.baz is not implemented

# Subclassing to allow instantiation
class Baz < Foo; end

object = Baz.new
object.bar  # raises NotImplementedError: Baz#bar is not implemented

Credits

Contributing

See CONTRIBUTING.md for details.

Copyright

Copyright © 2009-2013 Dan Kubb. See LICENSE for details.