Sha256: e9ced46595e11ca5e6191690f02bd9f9be169addc75b964cfe53fe6f7986cffe

Contents?: true

Size: 475 Bytes

Versions: 20

Compression:

Stored size: 475 Bytes

Contents

# If you want to use this concern, you need to add a boolean field 'visible' to
# the model.
module Concerns
  module Visible
    extend ActiveSupport::Concern

    included do
      scope :visible, ->{ where(visible: true) }
      scope :hidden, ->{ where('visible = 0 OR visible IS NULL') }
    end

    def hidden?
      !visible?
    end

    def hide!
      update_attribute :visible, false
    end

    def show!
      update_attribute :visible, true
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
udongo-5.3.1 app/models/concerns/visible.rb
udongo-5.3.0 app/models/concerns/visible.rb
udongo-5.2.0 app/models/concerns/visible.rb
udongo-5.1.0 app/models/concerns/visible.rb
udongo-5.0.2 app/models/concerns/visible.rb
udongo-5.0.1 app/models/concerns/visible.rb
udongo-5.0.0 app/models/concerns/visible.rb
udongo-4.0.0 app/models/concerns/visible.rb
udongo-3.0.0 app/models/concerns/visible.rb
udongo-2.0.4 app/models/concerns/visible.rb
udongo-2.0.3 app/models/concerns/visible.rb
udongo-2.0.2 app/models/concerns/visible.rb
udongo-2.0.1 app/models/concerns/visible.rb
udongo-2.0.0 app/models/concerns/visible.rb
udongo-1.0.4 app/models/concerns/visible.rb
udongo-1.0.3 app/models/concerns/visible.rb
udongo-1.0.2 app/models/concerns/visible.rb
udongo-1.0.1 app/models/concerns/visible.rb
udongo-1.0.0 app/models/concerns/visible.rb
udongo-0.1.0 app/models/concerns/visible.rb