Module: Filigree::AbstractClass
- Included in:
- BasicPattern, MultipleObjectPattern, SingleObjectPattern
- Defined in:
- lib/filigree/abstract_class.rb
Overview
A module the implements the abstract class and abstract method patterns.
Class Method Summary collapse
-
.extended(klass) ⇒ void
Tell the extended class to install its instance class variables.
Instance Method Summary collapse
-
#abstract_method(name) ⇒ void
Declares a method with the given name.
-
#install_icvars ⇒ void
Install instance class variables in the extended class.
-
#new(*args) ⇒ Object
Raise an AbstractClassError if someone attempts to instantiate an abstract class.
Class Method Details
.extended(klass) ⇒ void
This method returns an undefined value.
Tell the extended class to install its instance class variables.
86 87 88 |
# File 'lib/filigree/abstract_class.rb', line 86 def self.extended(klass) klass.install_icvars end |
Instance Method Details
#abstract_method(name) ⇒ void
This method returns an undefined value.
Declares a method with the given name. If it is called it will raise an AbstractMethodError.
50 51 52 53 54 55 56 |
# 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 ⇒ void
This method returns an undefined value.
Install instance class variables in the extended class.
61 62 63 |
# File 'lib/filigree/abstract_class.rb', line 61 def install_icvars @abstract_class = self end |
#new(*args) ⇒ Object
Raise an AbstractClassError if someone attempts to instantiate an abstract class.
71 72 73 74 75 76 77 |
# File 'lib/filigree/abstract_class.rb', line 71 def new(*args) if @abstract_class == self raise AbstractClassError, self.name else super end end |