Class: DeadSimpleCMS::Group

Inherits:
Attribute::Collection show all
Includes:
Presenter::RenderMixin
Defined in:
lib/dead_simple_cms/group.rb,
lib/dead_simple_cms/group/configuration.rb,
lib/dead_simple_cms/group/presenter/base.rb,
lib/dead_simple_cms/group/presenter/render_mixin.rb

Overview

Public: A Group is essentially an Attribute::Collection with the ability to have it’s own groups on it with infinite nesting of groups.

Direct Known Subclasses

Section

Defined Under Namespace

Modules: Presenter Classes: Configuration

Constant Summary collapse

ROOT_IDENTIFIER =
:root

Instance Attribute Summary collapse

Attributes inherited from Attribute::Collection

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Presenter::RenderMixin

#display, #presenter_class, #render, #render_proc

Methods inherited from Attribute::Collection

#add_attribute, #persisted?, #update_attributes

Constructor Details

#initialize(identifier, options = {}) ⇒ Group

Returns a new instance of Group.



14
15
16
17
# File 'lib/dead_simple_cms/group.rb', line 14

def initialize(identifier, options={})
  @groups = DeadSimpleCMS::Group.new_dictionary
  super
end

Instance Attribute Details

#groupsObject (readonly)

Returns the value of attribute groups.



8
9
10
# File 'lib/dead_simple_cms/group.rb', line 8

def groups
  @groups
end

#parentObject

Returns the value of attribute parent.



9
10
11
# File 'lib/dead_simple_cms/group.rb', line 9

def parent
  @parent
end

Class Method Details

.rootObject



19
20
21
# File 'lib/dead_simple_cms/group.rb', line 19

def self.root
  new(ROOT_IDENTIFIER)
end

Instance Method Details

#add_group(group) ⇒ Object



33
34
35
36
37
# File 'lib/dead_simple_cms/group.rb', line 33

def add_group(group)
  group.parent = self
  groups.add(group)
  group_accessor(group)
end

#extend(*modules, &block) ⇒ Object

Public: Exend functionality for the current group.



24
25
26
27
# File 'lib/dead_simple_cms/group.rb', line 24

def extend(*modules, &block)
  modules << Module.new(&block) if block_given?
  super(*modules)
end

#root?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/dead_simple_cms/group.rb', line 29

def root?
  identifier == ROOT_IDENTIFIER
end