Exception: NRSER::AbstractMethodError
- Inherits:
-
NotImplementedError
- Object
- NotImplementedError
- NRSER::AbstractMethodError
- Defined in:
- lib/nrser/errors.rb
Overview
Extension of Ruby’s NotImplementedError to provide a useful message and convenient constructor for abstract methods.
Instance Method Summary collapse
-
#initialize(instance, method_name) ⇒ AbstractMethodError
constructor
Construct a new ‘AbstractMethodError`.
Constructor Details
#initialize(instance, method_name) ⇒ AbstractMethodError
Construct a new ‘AbstractMethodError`.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nrser/errors.rb', line 27 def initialize instance, method_name @instance = instance @method_name = method_name @method = instance.method @method_name = if @method.owner == instance.class NRSER.dedent <<-END Method #{ @method.owner.name }##{ @method_name } is abstract, meaning #{ @method.owner.name } is an abstract class and the invoking instance #{ @instance } should NOT have been constructed. END else NRSER.squish <<-END Method #{ @method.owner.name }##{ @method_name } is abstract and has not been implemented in invoking class #{ @instance.class }. If you *are* developing the invoking class #{ @instance.class } it (or a parent class between it and #{ @method.owner.name }) must implement ##{ @method_name }. If you *are not* developing #{ @instance.class } it should be treated as an abstract base class and should NOT be constructed. You need to find a subclass of #{ @instance.class } to instantiate or write your own. END end super end |