Sha256: bfbe0e5587b2fbe3393bfa4f013d2a9ab77daa41e19b1f61ec601f83668f67b2

Contents?: true

Size: 538 Bytes

Versions: 2

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module ChronoModel
  # Provides the TimeMachine API to non-temporal models that associate
  # temporal ones.
  #
  module TimeGate
    extend ActiveSupport::Concern

    include ChronoModel::Patches::AsOfTimeHolder

    module ClassMethods
      include ChronoModel::TimeMachine::Timeline

      def as_of(time)
        all.as_of_time!(time)
      end
    end

    def as_of(time)
      self.class.as_of(time).where(id: id).first!
    end

    def timeline
      self.class.timeline(self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chrono_model-3.0.1 lib/chrono_model/time_gate.rb
chrono_model-2.0.0 lib/chrono_model/time_gate.rb