module Filigree::AbstractClass

A module the implements the abstract class and abstract method patterns.

Public Class Methods

extended(klass) click to toggle source

Tell the extended class to install its instance class variables.

@return [void]

# File lib/filigree/abstract_class.rb, line 86
def self.extended(klass)
        klass.install_icvars
end

Public Instance Methods

abstract_method(name) click to toggle source

Declares a method with the given name. If it is called it will raise an AbstractMethodError.

@param [Symbol] name The name of the abstract method you with to declare

@return [void]

# File lib/filigree/abstract_class.rb, line 50
def abstract_method(name)
        abstract_class_name = @abstract_class.name

        define_method name do
                raise AbstractMethodError.new name, abstract_class_name
        end
end
install_icvars() click to toggle source

Install instance class variables in the extended class.

@return [void]

# File lib/filigree/abstract_class.rb, line 61
def install_icvars
        @abstract_class = self
end
new(*args) click to toggle source

Raise an AbstractClassError if someone attempts to instantiate an abstract class.

@param [Object] args The arguments to initialize.

@raise [AbstractClassError]

Calls superclass method
# File lib/filigree/abstract_class.rb, line 71
def new(*args)
        if self.instance_variable_defined?(:'@abstract_class') and @abstract_class == self
                raise AbstractClassError, self.name
        else
                super
        end
end