Sha256: 5cfac9a0f70a85accc42712b57b7c93d51638b79c5d60bb396f1db83197d6d50
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
require 'active_support' module ActsAsSpan class SpanKlass module Status extend ActiveSupport::Concern included do def current(query_date = Date.current) klass.where( (arel_table[start_field].lteq(query_date).or(arel_table[start_field].eq(nil))). and( arel_table[end_field].eq(nil).or(arel_table[end_field].gteq(query_date)) ) ) end alias_method :current_on, :current def future(query_date = Date.current) klass.where(arel_table[start_field].gt(query_date)) end alias_method :future_on, :future def expired(query_date = Date.current) klass.where(arel_table[end_field].lt(query_date)) end alias_method :expired_on, :expired alias_method :past_on, :expired alias_method :past, :expired def current_or_future_on(query_date = Date.current) klass.where( arel_table[start_field].lteq(query_date). and( arel_table[end_field].eq(nil). or(arel_table[end_field].gteq(query_date)) ). or(arel_table[start_field].gt(query_date)) ) end alias_method :current_or_future, :current_or_future_on end end end end
Version data entries
4 entries across 4 versions & 1 rubygems