lib/ductr/rufus_trigger.rb in ductr-0.1.1 vs lib/ductr/rufus_trigger.rb in ductr-0.1.2

- old
+ new

@@ -51,12 +51,13 @@ # @return [void] # def add(method, options) rufus_type = options.keys.first rufus_value = options.values.first + handler = callable(method, **options) - do_schedule(rufus_type, rufus_value, method) + do_schedule(rufus_type, rufus_value, handler) end # # Shutdown rufus-scheduler # @@ -76,31 +77,30 @@ def rufus Rufus::Scheduler.singleton end # - # Returns a callable object based on given scheduler, method_name and options. + # Returns a callable object based on given method and options. # - # @param [Scheduler] scheduler The scheduler instance - # @param [Symbol] method_name The scheduler's method name + # @param [Method] method The scheduler's method # @param [Hash] ** The option passed to the trigger annotation # # @return [#call] A callable object # - def callable(scheduler, method_name, **) - scheduler.method(method_name) + def callable(method, **) + method end # # Calls the Rufus::Scheduler#do_schedule private method with rufus-scheduler type, value and the callable object. # # @param [Symbol] rufus_type The rufus-scheduler type (`:once`, `:every`, `:interval` or `:cron`) # @param [String] rufus_value The rufus-scheduler value (e.g. `"10min"`) - # @param [#call] method The callable object (the scheduler's method in this case) + # @param [#call] handler The callable object (the scheduler's method in this case) # # @return [void] # - def do_schedule(rufus_type, rufus_value, method) - rufus.send(:do_schedule, rufus_type, rufus_value, nil, {}, false, method) + def do_schedule(rufus_type, rufus_value, handler) + rufus.send(:do_schedule, rufus_type, rufus_value, nil, {}, false, handler) end end end