Class: Fiona7::AttributeReaders::WidgetlistAsLinklist

Inherits:
AttributeReader show all
Defined in:
lib/fiona7/attribute_readers/widgetlist_as_linklist.rb

Instance Method Summary collapse

Methods inherited from AttributeReader

#initialize

Constructor Details

This class inherits a constructor from Fiona7::AttributeReaders::AttributeReader

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fiona7/attribute_readers/widgetlist_as_linklist.rb', line 6

def call
  linklist = self.obj.attr_values[self.attr_name] || []
  if !linklist.empty?
    widget_ids = []
    widgets = linklist.map do |link|
      widget_id = link["title"]
      # sometimes a released page references an unreleased widget
      # it is then impossible to load it into widget_pool
      # but the reference in the widgetlist field is still there
      # therefore we need to check if the widget has been loaded
      # into the pool - only then it can be included
      if valid_widget_id?(widget_id)
        widget_ids << widget_id
      end
    end

    widget_ids
  end
end