Class: ShopifyCLI::Tasks::TaskRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/tasks.rb

Instance Method Summary collapse

Constructor Details

#initializeTaskRegistry

Returns a new instance of TaskRegistry.



6
7
8
# File 'lib/shopify_cli/tasks.rb', line 6

def initialize
  @tasks = {}
end

Instance Method Details

#[](name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/shopify_cli/tasks.rb', line 14

def [](name)
  class_or_proc = @tasks[name]
  if class_or_proc.is_a?(Class)
    class_or_proc
  elsif class_or_proc.respond_to?(:call)
    class_or_proc.call
  else
    class_or_proc
  end
end

#add(const, name) ⇒ Object



10
11
12
# File 'lib/shopify_cli/tasks.rb', line 10

def add(const, name)
  @tasks[name] = const
end