Sha256: 975b6de0a1dc2a96d113b45ece4d2ee003bfb8835665086198a0554e24e654aa
Contents?: true
Size: 1.13 KB
Versions: 97
Compression:
Stored size: 1.13 KB
Contents
module Actions module Middleware class KeepCurrentTimezone < Dynflow::Middleware def delay(*args) pass(*args).tap { store_current_timezone } end def plan(*args) with_current_timezone do pass(*args).tap { store_current_timezone } end end def run(*args) restore_curent_timezone { pass(*args) } end def finalize restore_curent_timezone { pass } end # Run all execution plan lifecycle hooks as the original timezone def hook(*args) restore_curent_timezone { pass(*args) } end private def with_current_timezone if action.input[:current_timezone].nil? yield else restore_curent_timezone { yield } end end def store_current_timezone action.input[:current_timezone] = Time.zone.name end def restore_curent_timezone old_zone = Time.zone Time.zone = Time.find_zone(action.input[:current_timezone]) if action.input[:current_timezone].present? yield ensure Time.zone = old_zone end end end end
Version data entries
97 entries across 97 versions & 1 rubygems