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.



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

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



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

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