Sha256: 67da46d8037e61c0b0a5d401db6da0a20a7ac0e4a4819f5c8b96f3db03ccb536
Contents?: true
Size: 796 Bytes
Versions: 5
Compression:
Stored size: 796 Bytes
Contents
module ChronoModel # Provides the TimeMachine API to non-temporal models that associate # temporal ones. # module TimeGate extend ActiveSupport::Concern module ClassMethods def as_of(time) time = Conversions.time_to_utc_string(time.utc) if time.kind_of? Time virtual_table = select(%[ #{quoted_table_name}.*, #{connection.quote(time)} AS "as_of_time"] ).to_sql as_of = scoped.from("(#{virtual_table}) #{quoted_table_name}") as_of.instance_variable_set(:@temporal, time) return as_of end include TimeMachine::HistoryMethods::Timeline end def as_of(time) self.class.as_of(time).where(:id => self.id).first! end def timeline self.class.timeline(self) end end end
Version data entries
5 entries across 5 versions & 1 rubygems