Module: Snaptime::Versioned::Scopes::ClassMethods

Defined in:
lib/snaptime/versioned/scopes.rb

Instance Method Summary collapse

Instance Method Details

#_at_explicit_snaptime(snaptime = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/snaptime/versioned/scopes.rb', line 18

def _at_explicit_snaptime(snaptime = nil)
  if snaptime.nil?
    where(valid_to: nil, deleted: false)
  else
    where(
      arel_table[:valid_from].lteq(snaptime).and(
        arel_table[:valid_to].eq(nil).or(
          arel_table[:valid_to].gteq(snaptime)
        )
      ).and(
        arel_table[:deleted].eq(false)
      )
    )
  end
end

#at_snaptimeObject



34
35
36
# File 'lib/snaptime/versioned/scopes.rb', line 34

def at_snaptime
  _at_explicit_snaptime Snaptime.snaptime
end

#current_versionObject



13
14
15
16
# File 'lib/snaptime/versioned/scopes.rb', line 13

def current_version
  snaptime = Snaptime.snaptime
  _at_explicit_snaptime(snaptime)
end