Class: Thor::TaskHash
- Inherits:
-
OrderedHash
- Object
- OrderedHash
- Thor::TaskHash
- Defined in:
- lib/thor/lib/thor/task_hash.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #each(local = false, &block) ⇒ Object
-
#initialize(klass) ⇒ TaskHash
constructor
A new instance of TaskHash.
Methods inherited from OrderedHash
#+, #[]=, #initialize_copy, #values
Constructor Details
#initialize(klass) ⇒ TaskHash
Returns a new instance of TaskHash.
5 6 7 8 |
# File 'lib/thor/lib/thor/task_hash.rb', line 5 def initialize(klass) super() @klass = klass end |
Instance Method Details
#[](name) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/thor/lib/thor/task_hash.rb', line 15 def [](name) if task = super(name) || (@klass == Thor && @klass.superclass.tasks[name]) return task.with_klass(@klass) end Thor::Task.dynamic(name, @klass) end |
#each(local = false, &block) ⇒ Object
10 11 12 13 |
# File 'lib/thor/lib/thor/task_hash.rb', line 10 def each(local = false, &block) super() { |k, t| yield k, t.with_klass(@klass) } @klass.superclass.tasks.each { |k, t| yield k, t.with_klass(@klass) } unless local || @klass == Thor end |