Module: RailsAdmin::Config::HasGroups
- Included in:
- Sections::Base
- Defined in:
- lib/rails_admin/config/has_groups.rb
Instance Method Summary collapse
-
#group(name, &block) ⇒ Object
Accessor for a group.
-
#visible_groups ⇒ Object
Reader for groups that are marked as visible.
Instance Method Details
#group(name, &block) ⇒ Object
Accessor for a group
If group with given name does not yet exist it will be created. If a block is passed it will be evaluated in the context of the group
10 11 12 13 14 15 |
# File 'lib/rails_admin/config/has_groups.rb', line 10 def group(name, &block) group = parent.groups.detect { |g| name == g.name } group ||= (parent.groups << RailsAdmin::Config::Fields::Group.new(self, name)).last group.tap { |g| g.section = self }.instance_eval(&block) if block group end |
#visible_groups ⇒ Object
Reader for groups that are marked as visible
18 19 20 21 22 |
# File 'lib/rails_admin/config/has_groups.rb', line 18 def visible_groups parent.groups.collect { |f| f.section = self; f.with(bindings) }.select(&:visible?).select do |g| # rubocop:disable Style/Semicolon g.visible_fields.present? end end |