Sha256: 483fa62a077ebc51b5ac90cf8fd60c9ff481ba7832bbde3ac679c2713385139c

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

require "rake"
require "active_support/core_ext/string"

module OopsARake
  class Registry
    @tasks = {}

    def self.register(task_class)
      task_name = task_class.name.underscore.gsub("/", ":").delete_suffix("_task")

      task = Rake::Task.define_task(task_name) do |_, args|
        task_class.new.call(*args)
      end

      @tasks[task_class] = task
      task
    end

    def self.fetch(task_class)
      @tasks.fetch(task_class)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oops_a_rake-0.1.0 lib/oops_a_rake/registry.rb