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.



6
7
8
9
10
# File 'lib/rails_admin/config/hideable.rb', line 6

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)


13
14
15
# File 'lib/rails_admin/config/hideable.rb', line 13

def hidden?
  !visible
end

#hide(&block) ⇒ Object

Writer to hide object.



18
19
20
# File 'lib/rails_admin/config/hideable.rb', line 18

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

#show(&block) ⇒ Object

Writer to show field.



23
24
25
# File 'lib/rails_admin/config/hideable.rb', line 23

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