Sha256: d7299cd9bd2348f0fa219d8e347cb0965a53c430563bda22b6c09f7fde4996ad
Contents?: true
Size: 804 Bytes
Versions: 1
Compression:
Stored size: 804 Bytes
Contents
module Screengem module Factories # # Knows how to create a Task from a task name. # class TaskFactory < BasicObject include ::Singleton def method_missing(task_name, *args) task_class_name = "#{task_name}_task".camelize task_class = "#{task_scope}::#{task_class_name}".constantize task_class.new(*args) rescue => e TaskError.new(<<~MSG) Unable to create task: '#{task_class_name}'. Details: #{e.message} MSG end def respond_to_missing?(_task_name, *) true end class TaskError < ::Screengem::Task include FactoryCreationError end private def task_scope @task_scope ||= ::Screengem.configuration.task_scope end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
screengem-0.17.0 | lib/screengem/factories/task_factory.rb |