Module: RailsAdmin::Config::HasGroups

Included in:
Sections::Base
Defined in:
lib/rails_admin/config/has_groups.rb

Instance Method Summary collapse

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



12
13
14
15
16
17
# File 'lib/rails_admin/config/has_groups.rb', line 12

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_groupsObject

Reader for groups that are marked as visible



20
21
22
23
24
# File 'lib/rails_admin/config/has_groups.rb', line 20

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