Exception: ImplementInSubclass
- Inherits:
-
StandardError
- Object
- StandardError
- ImplementInSubclass
- Defined in:
- app/services/implement_in_subclass.rb
Overview
To force an interface raise this error:
raise ImplementInSubclass.new(self)
to raise an error with a nice message
Instance Method Summary collapse
-
#initialize(klass) ⇒ ImplementInSubclass
constructor
A new instance of ImplementInSubclass.
- #message ⇒ Object
- #method_to_be_implemented ⇒ Object
Constructor Details
#initialize(klass) ⇒ ImplementInSubclass
Returns a new instance of ImplementInSubclass.
5 6 7 8 9 |
# File 'app/services/implement_in_subclass.rb', line 5 def initialize(klass) @calling_method = caller_locations(2,1)[0] @concerning_class = klass.is_a?(Class) ? klass : klass.class # can be called from instance or class super end |
Instance Method Details
#message ⇒ Object
15 16 17 |
# File 'app/services/implement_in_subclass.rb', line 15 def "Implement method: #{method_to_be_implemented} in a subclass of #{@concerning_class.name}" end |
#method_to_be_implemented ⇒ Object
11 12 13 |
# File 'app/services/implement_in_subclass.rb', line 11 def method_to_be_implemented @calling_method.label end |