Sha256: 8353d46ed5d1b1d18ba17bc4f9931f180f2b1cbb420993dea7bdface5bc72ceb
Contents?: true
Size: 1.11 KB
Versions: 51
Compression:
Stored size: 1.11 KB
Contents
module Scrivito # @api public # The +WidgetCollection+ represents all {Scrivito::BasicWidget Widgets} referenced by an # {Scrivito::BasicObj Obj} or its subwidgets. class WidgetCollection include Enumerable def initialize(obj) @obj = obj end # @api public # Access a {Scrivito::BasicWidget Widget} by its +id+ # @param [String] widget_id the id of the widget # @return [Scrivito::BasicWidget, nil] the Widget with the given +widget_id+ or nil def [](widget_id) obj.widget_from_pool(widget_id) end # @api public # # Enables you to iterate the {Scrivito::BasicWidget Widgets} of an {Scrivito::BasicObj Obj}. # Includes the {https://ruby-doc.org/core-2.1.0/Enumerable.html Enumerable} mixin # and thereby provides methods like +map+ or +select+. # @yield [Scrivito::BasicWidget] the {Scrivito::BasicWidget Widgets} of an {Scrivito::BasicObj Obj} # # @example Array of all widget ids # obj.widgets.map { |widget| widget.id } def each(&block) obj.contained_widgets.each(&block) end private attr_reader :obj end end
Version data entries
51 entries across 51 versions & 1 rubygems