Sha256: 84c3a474a42dec8c8041bed415486bbf47e66dab05e12a891f2a81f536e7d56a

Contents?: true

Size: 604 Bytes

Versions: 7

Compression:

Stored size: 604 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
rails_admin-3.0.0 lib/rails_admin/config/hideable.rb
rails_admin-3.0.0.rc4 lib/rails_admin/config/hideable.rb
rails_admin-3.0.0.rc3 lib/rails_admin/config/hideable.rb
rails_admin-3.0.0.rc2 lib/rails_admin/config/hideable.rb
rails_admin-3.0.0.rc lib/rails_admin/config/hideable.rb
rails_admin-3.0.0.beta2 lib/rails_admin/config/hideable.rb
rails_admin-3.0.0.beta lib/rails_admin/config/hideable.rb