Class: Thor::Task::Dynamic

Inherits:
Thor::Task show all
Defined in:
lib/vendor/thor/lib/thor/task.rb

Overview

A dynamic task that handles method missing scenarios.

Constant Summary

Constants inherited from Thor::Task

FILE_REGEXP

Instance Attribute Summary

Attributes inherited from Thor::Task

#description, #name, #options, #usage

Instance Method Summary collapse

Methods inherited from Thor::Task

#formatted_usage, #initialize_copy

Methods inherited from Struct

json_create, #to_json

Constructor Details

#initialize(name, options = nil) ⇒ Dynamic

Returns a new instance of Dynamic.



7
8
9
# File 'lib/vendor/thor/lib/thor/task.rb', line 7

def initialize(name, options=nil)
  super(name.to_s, "A dynamically-generated task", name.to_s, options)
end

Instance Method Details

#run(instance, args = []) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/vendor/thor/lib/thor/task.rb', line 11

def run(instance, args=[])
  if (instance.methods & [name.to_s, name.to_sym]).empty?
    super
  else
    instance.class.handle_no_task_error(name)
  end
end