Sha256: 8760a867647d8bf500cf0ffc1db89aee4911b96de24249c89a225b8246527b9b
Contents?: true
Size: 664 Bytes
Versions: 3
Compression:
Stored size: 664 Bytes
Contents
module ActiveRegulation module Activation extend ActiveSupport::Concern included do scope :active, -> { where(inactivated_at: nil) } scope :inactive, -> { where.not(inactivated_at: nil) } end def active! update(inactivated_at: nil) if inactive? end def inactive! update(inactivated_at: Time.now) if active? end def active? inactivated_at.nil? end def inactive? !active? end def inactivated_at_or_time active? ? Time.now : inactivated_at end def to_activation I18n.t("active_regulation.activation.#{active? ? :active : :inactive}") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_regulation-2.4.0 | lib/active_regulation/activation.rb |
active_regulation-2.3.0 | lib/active_regulation/activation.rb |
active_regulation-2.2.6 | lib/active_regulation/activation.rb |