Complete the code to define a hook method that can be overridden.
def [1] # default behavior end
The method hook_method is a placeholder that can be overridden by subclasses or users to customize behavior.
Complete the code to call the hook method inside another method.
def perform puts 'Starting task' [1] puts 'Task finished' end
The perform method calls hook_method to allow customization during execution.
Fix the error in the subclass to override the hook method correctly.
class CustomTask < BaseTask def [1] puts 'Custom behavior' end end
Overriding hook_method in the subclass allows custom behavior during perform.
Fill both blanks to define a base class with a hook and a method that calls it.
class BaseTask def [1] # default hook end def [2] puts 'Begin' [1] puts 'End' end end
The base class defines hook_method as the hook and perform to call it.
Fill all three blanks to create a subclass that overrides the hook and runs the task.
class CustomTask < BaseTask def [1] puts 'Custom action' end end task = CustomTask.new [2] task.[3]
The subclass overrides hook_method. We create an instance task and call perform to run it.