Class: Class

Inherits:
Object
  • Object
show all
Defined in:
lib/foundation_kit/class.rb

Overview

Adds additional behavior to Class

Author:

  • jcrum

Instance Method Summary collapse

Instance Method Details

#abstract_definition(*method_names) ⇒ Object

Provides the ability to define an abstract method on a class

Parameters:

  • *args

Raises:

  • (FoundationKit::Errors::ClassNotImplmentedError)
  • (FoundationKit::Errors::MethodNotImplmentedError)


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/foundation_kit/class.rb', line 15

def abstract_definition(*method_names)
  # rubocop:disable Style/GuardClause, Lint/UnusedBlockArgument, Lint/ShadowingOuterLocalVariable
  method_names.each do |method_name|
    define_method(method_name) do |*args|
      if method_name == :initialize
        raise FoundationKit::Errors::ClassNotImplementedError.new(class_name: self.class.name)
      else
        raise FoundationKit::Errors::MethodNotImplementedError.new(class_name: self.class.name, method_name: method_name)
      end
    end
    # rubocop:enable Style/GuardClause, Lint/UnusedBlockArgument, Lint/ShadowingOuterLocalVariable
  end
end