Module: RailsAdmin::Config::Sections
- Included in:
- Model
- Defined in:
- lib/rails_admin/config/sections.rb,
lib/rails_admin/config/sections/list.rb,
lib/rails_admin/config/sections/show.rb,
lib/rails_admin/config/sections/create.rb,
lib/rails_admin/config/sections/export.rb,
lib/rails_admin/config/sections/update.rb,
lib/rails_admin/config/sections/navigation.rb
Overview
Sections describe different views in the RailsAdmin engine. Configurable sections are list and navigation.
Each section’s class object can store generic configuration about that section (such as the number of visible tabs in the main navigation), while the instances (accessed via model configuration objects) store model specific configuration (such as the visibility of the model).
Defined Under Namespace
Classes: Create, Export, List, Navigation, Show, Update
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rails_admin/config/sections.rb', line 19 def self.included(klass) # Register accessors for all the sections in this namespace constants.each do |name| section = "RailsAdmin::Config::Sections::#{name}".constantize name = name.to_s.downcase.to_sym klass.send(:define_method, name) do |&block| @sections = {} unless @sections unless @sections[name] @sections[name] = section.new(self) end @sections[name].instance_eval &block if block @sections[name] end # Register a shortcut to define the model's label for each section. klass.send(:define_method, "label_for_#{name}") do # TODO: Remove this warning in the next release, after people have updated their applications $stderr.puts("WARNING: label_for_#{name} has been removed. This configuration will be ignored. Model names can be configured with 'label' and section-specific names are no longer supported. See README for details.") end # Register a shortcut to hide the model for each section. klass.send(:define_method, "hide_from_#{name}") do |&block| # TODO: Remove this warning in the next release, after people have updated their applications $stderr.puts("WARNING: hide_from_#{name} has been removed. This configuration will be ignored. Model visibility can be configured with 'hide', 'show' and 'visibility'. Section-specific visibility is no longer supported. See README for details.") end # Register a shortcut to show the model for each section. klass.send(:define_method, "show_in_#{name}") do |&block| # TODO: Remove this warning in the next release, after people have updated their applications $stderr.puts("WARNING: show_in_#{name} has been removed. This configuration will be ignored. Model visibility can be configured with 'hide', 'show' and 'visibility'. Section-specific visibility is no longer supported. See README for details.") end end end |