Sha256: dc399dbf23eac9190be7a93ebc5f48f7f9b411be09aad982fe8c8cbab32a5fef
Contents?: true
Size: 663 Bytes
Versions: 5
Compression:
Stored size: 663 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
5 entries across 5 versions & 1 rubygems