Module: Sunrise::Config::HasGroups

Included in:
Form, Index
Defined in:
lib/sunrise/config/has_groups.rb

Instance Method Summary collapse

Instance Method Details

#group(name, options = nil, &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
# File 'lib/sunrise/config/has_groups.rb', line 12

def group(name, options = nil, &block)
  groups[name] ||= Sunrise::Config::Group.new(abstract_model, self, name, options)
  groups[name].instance_eval &block if block
  groups[name]
end

#groups ⇒ Object

Reader for groups



19
20
21
# File 'lib/sunrise/config/has_groups.rb', line 19

def groups
  @groups ||= {}
end

#visible_groups ⇒ Object

Reader for groups that are marked as visible



24
25
26
# File 'lib/sunrise/config/has_groups.rb', line 24

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