lib/arsenicum/task/class_dispatcher.rb in arsenicum-0.1.0 vs lib/arsenicum/task/class_dispatcher.rb in arsenicum-0.1.1

- old
+ new

@@ -1,15 +1,18 @@ class Arsenicum::Task::ClassDispatcher < Arsenicum::Task + include Arsenicum::Util + attr_reader :target_class, :target_method private :target_class, :target_method def initialize(id, options) super(id) - @target_class = options.delete :type - @target_method = options.delete :target + (klass, method) = options[:target].split('#', 2) + @target_class = constantize klass + @target_method = target_class.instance_method method.to_sym end def run(*parameters) - target_class.new.__send__ target_method, *parameters + target_method.bind(target_class.new).call *parameters end end