lib/sequel/plugins/bitemporal.rb in sequel_bitemporal-0.4.8 vs lib/sequel/plugins/bitemporal.rb in sequel_bitemporal-0.4.9
- old
+ new
@@ -3,23 +3,25 @@
module Bitemporal
def self.as_we_knew_it(time)
raise ArgumentError, "requires a block" unless block_given?
key = :sequel_plugins_bitemporal_point_in_time
previous, Thread.current[key] = Thread.current[key], time.to_time
- yield
+ result = yield
Thread.current[key] = previous
+ result
end
def self.point_in_time
Thread.current[:sequel_plugins_bitemporal_point_in_time] || Time.now
end
def self.at(time)
raise ArgumentError, "requires a block" unless block_given?
key = :sequel_plugins_bitemporal_now
previous, Thread.current[key] = Thread.current[key], time.to_time
- yield
+ result = yield
Thread.current[key] = previous
+ result
end
def self.now
Thread.current[:sequel_plugins_bitemporal_now] || Time.now
end