Module: TransactionTimestamps::Timestamp
- Defined in:
- lib/transaction_timestamps/timestamp.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/transaction_timestamps/timestamp.rb', line 5 def self.included(base) base.class_eval do # override the original timestamp with one our own that returns transaction-based timestamps alias_method :original_current_time_from_proper_timezone, :current_time_from_proper_timezone def current_time_from_proper_timezone if current_transaction_time else original_current_time_from_proper_timezone end end end end |
Instance Method Details
#current_transaction_time ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/transaction_timestamps/timestamp.rb', line 19 def current_transaction_time if new_transaction? @@cached_timestamp = adjust_time_to_timezone(db_transaction_time) else @@cached_timestamp end end |