Sha256: 633a31add4736854874a6b564234eeac6866000b0f0b4d222a0e495c9b6840ea
Contents?: true
Size: 637 Bytes
Versions: 3
Compression:
Stored size: 637 Bytes
Contents
module ActiveRegulation module Visibility extend ActiveSupport::Concern included do scope :visible, -> { where(invisible_at: nil) } scope :invisible, -> { where.not(invisible_at: nil) } end def invisible! update(invisible_at: Time.now) end def visible! update(invisible_at: nil) end def invisible? !visible? end def visible? invisible_at.nil? end def invisible_at_or_time visible? ? Time.now : invisible_at end def to_visibility I18n.t("active_regulation.visibility.#{visible? ? :visible : :invisible}") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_regulation-2.4.0 | lib/active_regulation/visibility.rb |
active_regulation-2.3.0 | lib/active_regulation/visibility.rb |
active_regulation-2.2.6 | lib/active_regulation/visibility.rb |