Strelka::

AbstractClass

module

Hides your class's ::new method and adds a pure_virtual method generator for defining API methods. If subclasses of your class don't provide implementations of “pure_virtual” methods, NotImplementedErrors will be raised if they are called.

# AbstractClass
class MyBaseClass
    extend Strelka::AbstractClass

    # Define a method that will raise a NotImplementedError if called
    pure_virtual :api_method
end

Public Class Methods

anchor
extended( mod )

Extension callback – mark the extended object's .new as private

# File lib/strelka/mixins.rb, line 28
def self::extended( mod )
        super
        mod.class_eval { private_class_method :new }
end
anchor
included( mod )

Inclusion callback – support backward-compatible inclusion.

# File lib/strelka/mixins.rb, line 35
def self::included( mod )
        mod.extend( self )
        super
end

Public Instance Methods

anchor
inherited( subclass )

Inheritance callback – Turn subclasses' .new methods back to public.

# File lib/strelka/mixins.rb, line 55
def inherited( subclass )
        subclass.module_eval { public_class_method :new }
        super
end
anchor
pure_virtual( *syms )

Define one or more “virtual” methods which will raise NotImplementedErrors when called via a concrete subclass.

# File lib/strelka/mixins.rb, line 43
def pure_virtual( *syms )
        syms.each do |sym|
                define_method( sym ) do |*args|
                        raise ::NotImplementedError,
                        "%p does not provide an implementation of #%s" % [ self.class, sym ],
                        caller(1)
                end
        end
end