Sha256: b05d2ea15dce8299a2687fa360740777affc0f7cdbd3739f500549f5fd938607

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Section < Common::Content::DoubleModel
          passkey     :id
          passthrough :patch_ver, :weight, :type
          passthrough :heading, :left_heading, :right_heading
          passarray   :component_ids, :left_component_ids, :right_component_ids

          def split?
            doc && doc["type"] == "split"
          end

          def all_component_ids
            return component_ids.to_a unless split?
            left_component_ids.to_a | right_component_ids.to_a
          end

          def component?(id)
            all_component_ids.include?(id)
          end

          def components
            sec_ids = all_component_ids
            root.components.values_at(*sec_ids).select.with_index do |fld, i|
              puts "Warning: section #{id} points to missing field #{sec_ids[i]}" if !fld
              fld && (!block_given? || yield(fld))
            end
          end

        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecoportal-api-oozes-0.5.7 lib/ecoportal/api/v2/page/section.rb
ecoportal-api-oozes-0.5.6 lib/ecoportal/api/v2/page/section.rb
ecoportal-api-oozes-0.5.5 lib/ecoportal/api/v2/page/section.rb