Module: RailsAdmin::Config::Hideable

Included in:
Actions::Base, Fields::Base, Fields::Group, Model
Defined in:
lib/rails_admin/config/hideable.rb

Overview

Defines a visibility configuration

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Visibility defaults to true.



8
9
10
11
12
# File 'lib/rails_admin/config/hideable.rb', line 8

def self.included(klass)
  klass.register_instance_option :visible? do
    !root.try :excluded?
  end
end

Instance Method Details

#hidden?Boolean

Reader whether object is hidden.

Returns:

  • (Boolean)


15
16
17
# File 'lib/rails_admin/config/hideable.rb', line 15

def hidden?
  !visible
end

#hide(&block) ⇒ Object

Writer to hide object.



20
21
22
# File 'lib/rails_admin/config/hideable.rb', line 20

def hide(&block)
  visible block ? proc { instance_eval(&block) == false } : false
end

#show(&block) ⇒ Object

Writer to show field.



25
26
27
# File 'lib/rails_admin/config/hideable.rb', line 25

def show(&block)
  visible block || true
end