lib/active_regulation/suspension.rb in active_regulation-4.0.3 vs lib/active_regulation/suspension.rb in active_regulation-5.0.0
- old
+ new
@@ -1,16 +1,18 @@
+# frozen_string_literal: true
+
module ActiveRegulation
module Suspension
extend ActiveSupport::Concern
included do
scope :suspended, -> { where.not(suspended_at: nil) }
scope :unsuspended, -> { where(suspended_at: nil) }
end
def suspend!
- update(suspended_at: Time.now) if unsuspended?
+ update(suspended_at: Time.current) if unsuspended?
end
def unsuspend!
update(suspended_at: nil) if suspended?
end
@@ -22,10 +24,10 @@
def unsuspended?
suspended_at.nil?
end
def suspended_at_or_time
- suspended? ? Time.now : suspended_at
+ suspended? ? Time.current : suspended_at
end
def to_suspension
I18n.t("active_regulation.suspension.#{suspended? ? :suspended : :unsuspended}")
end