module TiltHydrometer::ThrotteledExecution
Public Instance Methods
execution_allowed?(uuid)
click to toggle source
# File lib/tilt_hydrometer/throttled_execution.rb, line 16 def execution_allowed?(uuid) return true if timers[uuid].nil? # puts @interval.inspect timers[uuid] + @interval < Time.now.utc end
reset_timer(uuid)
click to toggle source
# File lib/tilt_hydrometer/throttled_execution.rb, line 24 def reset_timer(uuid) timers[uuid] = Time.now.utc end
throtteled_execution(uuid) { || ... }
click to toggle source
# File lib/tilt_hydrometer/throttled_execution.rb, line 5 def throtteled_execution(uuid) unless execution_allowed?(uuid) LOGGER.debug('Execution got throtteled') return end reset_timer(uuid) yield end
timers()
click to toggle source
# File lib/tilt_hydrometer/throttled_execution.rb, line 28 def timers @timers ||= {} end