Module: Extensions::TimeBoundedRecord::ActiveRecord::Base

Defined in:
lib/extensions/time_bounded_record/active_record/base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#currently_active?Boolean

Returns True if current time is between start_at and end_at.

Returns:

  • (Boolean)

    True if current time is between start_at and end_at.


25
26
27
# File 'lib/extensions/time_bounded_record/active_record/base.rb', line 25

def currently_active?
  started? && !ended?
end

#ended?Boolean

Returns True if end_at is a past time.

Returns:

  • (Boolean)

    True if end_at is a past time.


30
31
32
# File 'lib/extensions/time_bounded_record/active_record/base.rb', line 30

def ended?
  end_at.present? && Time.zone.now > end_at
end

#started?Boolean

Returns True if start_at is a future time.

Returns:

  • (Boolean)

    True if start_at is a future time.


20
21
22
# File 'lib/extensions/time_bounded_record/active_record/base.rb', line 20

def started?
  start_at.blank? || start_at <= Time.zone.now
end