Module: RailsAdmin::Config::HasGroups

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

Instance Method Summary collapse

Instance Method Details

#fields_of_group(group, &block) ⇒ Object

Access fields by their group



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

def fields_of_group(group, &block)
  selected = @fields.select {|f| group == f.group }
  if block
    selected.each {|f| f.instance_eval &block }
  end
  selected
end

#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



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

def group(name, &block)
  group = @groups.find {|g| name == g.name }
  if group.nil?
    group = (@groups << RailsAdmin::Config::Fields::Group.new(self, name)).last
  end
  group.instance_eval &block if block
  group
end

#groupsObject

Reader for groups



29
30
31
# File 'lib/rails_admin/config/has_groups.rb', line 29

def groups
  @groups
end

#visible_groupsObject

Reader for groups that are marked as visible



34
35
36
# File 'lib/rails_admin/config/has_groups.rb', line 34

def visible_groups
  groups.select {|g| g.visible? }
end