# To force an interface raise this error:
#   raise ImplementInSubclass.new(self)
# to raise an error with a nice message
class ImplementInSubclass < StandardError
  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

  def method_to_be_implemented
    @calling_method.label
  end

  def message
    "Implement method: #{method_to_be_implemented} in a subclass of #{@concerning_class.name}"
  end
end
