Sha256: 9b35923ce25b41798758c762fa747cc2cdb9cf7874683e8ba85ebbf91a06aa8d

Contents?: true

Size: 1003 Bytes

Versions: 19

Compression:

Stored size: 1003 Bytes

Contents

require 'fiona7/attribute_readers/attribute_reader'

module Fiona7
  module AttributeReaders
    class WidgetlistAsLinklist < AttributeReader
      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

      protected
      def valid_widget_id?(widget_id)
        self.widget_resolver && self.widget_resolver.path_map[widget_id]
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.6.1.1.1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.2.0.2.3 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.2.0.2.1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.2.0.2.2 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.2.0.1.4 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.2.0.1.3 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.5.3.1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.4.3.0 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.3.2.0 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.3.2.0.pre.beta1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.2.1.0.pre.beta1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.5.2.0.0 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb
infopark_fiona7-1.2.0.1.1 lib/fiona7/attribute_readers/widgetlist_as_linklist.rb