Class: Scrivito::WidgetCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
app/cms/scrivito/widget_collection.rb

Overview

The WidgetCollection represents all Widgets referenced by an Obj or its subwidgets.

Instance Method Summary collapse

Instance Method Details

#[](widget_id) ⇒ Scrivito::BasicWidget?

Access a Widget by its id

Parameters:

  • widget_id (String)

    the id of the widget

Returns:



16
17
18
# File 'app/cms/scrivito/widget_collection.rb', line 16

def [](widget_id)
  obj.widget_from_pool(widget_id)
end

#each {|Scrivito::BasicWidget| ... } ⇒ Object

Enables you to iterate the Widgets of an Obj. Includes the Enumerable mixin and thereby provides methods like map or select.

Examples:

Array of all widget ids

obj.widgets.map { |widget| widget.id }

Yields:



29
30
31
# File 'app/cms/scrivito/widget_collection.rb', line 29

def each(&block)
  obj.contained_widgets.each(&block)
end