Module: SleepingKingStudios::Tools::Toolbox::Subclass
- Defined in:
- lib/sleeping_king_studios/tools/toolbox/subclass.rb
Overview
Mixin for partially applying constructor parameters.
Instance Method Summary collapse
-
#subclass(*class_arguments, **class_keywords) { ... } ⇒ Class
Creates a subclass with partially applied constructor parameters.
Instance Method Details
#subclass(*class_arguments, **class_keywords) { ... } ⇒ Class
Creates a subclass with partially applied constructor parameters.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sleeping_king_studios/tools/toolbox/subclass.rb', line 38 def subclass(*class_arguments, **class_keywords, &class_block) # rubocop:disable Metrics/MethodLength subclass = Class.new(self) subclass.define_method :initialize do |*args, **kwargs, &block| super( *class_arguments, *args, **class_keywords, **kwargs, &(block || class_block) ) end subclass end |