Sha256: 5afe99c5f939bc3b7c88ac89c80fd28b7367707ea30ec53d3b59852964ef0b28

Contents?: true

Size: 635 Bytes

Versions: 13

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

module RailsAdmin
  module Config
    # Defines a visibility configuration
    module Hideable
      # Visibility defaults to true.
      def self.included(klass)
        klass.register_instance_option :visible? do
          !root.try :excluded?
        end
      end

      # Reader whether object is hidden.
      def hidden?
        !visible
      end

      # Writer to hide object.
      def hide(&block)
        visible block ? proc { instance_eval(&block) == false } : false
      end

      # Writer to show field.
      def show(&block)
        visible block || true
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails_admin-3.3.0 lib/rails_admin/config/hideable.rb
rails_admin-3.2.1 lib/rails_admin/config/hideable.rb
rails_admin-3.2.0 lib/rails_admin/config/hideable.rb
rails_admin-3.2.0.rc lib/rails_admin/config/hideable.rb
rails_admin-3.2.0.beta lib/rails_admin/config/hideable.rb
rails_admin-3.1.4 lib/rails_admin/config/hideable.rb
rails_admin-3.1.3 lib/rails_admin/config/hideable.rb
rails_admin-3.1.2 lib/rails_admin/config/hideable.rb
rails_admin-3.1.1 lib/rails_admin/config/hideable.rb
rails_admin-3.1.0 lib/rails_admin/config/hideable.rb
rails_admin-3.1.0.rc2 lib/rails_admin/config/hideable.rb
rails_admin-3.1.0.rc lib/rails_admin/config/hideable.rb
rails_admin-3.1.0.beta lib/rails_admin/config/hideable.rb