Sha256: 4f323627d86216979da011017513be9e529837d7f0808e0dac01166a8c71e453
Contents?: true
Size: 870 Bytes
Versions: 2
Compression:
Stored size: 870 Bytes
Contents
# frozen_string_literal: true module Lite module Regulation module Containment extend ActiveSupport::Concern included do scope :contained, -> { where.not(contained_at: nil) } scope :uncontained, -> { where(contained_at: nil) } end def contain! return true if contained? update(contained_at: Time.current) end def contained? !uncontained? end def contained_at_or_time return contained_at if contained? Lite::Regulation::Base.timestamp end def to_containment I18n.t("lite.regulation.containment.#{uncontained? ? :uncontained : :contained}") end def uncontain! return true if uncontained? update(contained_at: nil) end def uncontained? contained_at.nil? end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lite-regulation-1.0.1 | lib/lite/regulation/containment.rb |
lite-regulation-1.0.0 | lib/lite/regulation/containment.rb |