Module: Batteries::Tasks

Defined in:
lib/batteries/tasks.rb,
lib/batteries/tasks/notes.rb,
lib/batteries/tasks/secret.rb,
lib/batteries/tasks/migrations.rb

Defined Under Namespace

Classes: Migrations, Notes, Secret

Class Method Summary collapse

Class Method Details

.default_tasksObject



20
21
22
# File 'lib/batteries/tasks.rb', line 20

def default_tasks
  %i(notes migrations secret)
end

.new(tasks: default_tasks) {|task_options| ... } ⇒ Object

Yields:

  • (task_options)


10
11
12
13
14
15
16
17
18
# File 'lib/batteries/tasks.rb', line 10

def new(tasks: default_tasks)
  task_options = setup_task_options(tasks)

  yield task_options if block_given?

  tasks.each do |task|
    const_get(task.to_s.capitalize).new(options: task_options[task].to_h)
  end
end

.setup_task_options(tasks) ⇒ Object



24
25
26
27
28
# File 'lib/batteries/tasks.rb', line 24

def setup_task_options(tasks)
  tasks.each_with_object(OpenStruct.new) do |task, memo|
    memo.send("#{task}=", OpenStruct.new)
  end
end