Module: TemporalTables::TemporalClass::ClassMethods

Defined in:
lib/temporal_tables/temporal_class.rb

Instance Method Summary collapse

Instance Method Details

#build_temporal_constraint(at_value) ⇒ Object

An object at a given time should fall within the range, excluding the effective end date. However, when using ‘9999-12-31’, this is effectively infinity and should not be excluded.



79
80
81
82
83
# File 'lib/temporal_tables/temporal_class.rb', line 79

def build_temporal_constraint(at_value)
  (arel_table[:eff_to].gt(at_value).or(arel_table[:eff_to].eq(TemporalTables::END_OF_TIME))).and(
    arel_table[:eff_from].lteq(at_value)
  )
end

#orig_classObject



71
72
73
# File 'lib/temporal_tables/temporal_class.rb', line 71

def orig_class
  name.sub(/History$/, '').constantize
end