Sha256: d1ac1c27270dd432814685173727dc771e23d1fdb25b74b3bb7e7336264e9b18
Contents?: true
Size: 835 Bytes
Versions: 2
Compression:
Stored size: 835 Bytes
Contents
# frozen_string_literal: true module Lite module Regulation module Visibility extend ActiveSupport::Concern included do scope :invisible, -> { where.not(invisible_at: nil) } scope :visible, -> { where(invisible_at: nil) } end def invisible! return true if invisible? update(invisible_at: Time.current) end def visible! return true if visible? update(invisible_at: nil) end def invisible? !visible? end def invisible_at_or_time return invisible_at if invisible? Lite::Regulation::Base.timestamp end def to_visibility I18n.t("lite.regulation.visibility.#{:in if invisible?}visible") end def visible? invisible_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/visibility.rb |
lite-regulation-1.0.0 | lib/lite/regulation/visibility.rb |