Sha256: 2b0c6f4e6ae24a680348570f6171149fe19b098e34a69db5f2ecdd6b8a7ca1bb

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Stage < Common::Content::DoubleModel
          passkey     :id
          passthrough :patch_ver
          passthrough :name, :ordering
          passarray   :subtags, order_matters: false
          passarray   :section_ids
          passthrough :status
          passboolean :complete, :lock_after_completion

          embeds_many :permits, klass: "Ecoportal::API::V2::Page::Permit"
          passboolean :disable_direct_permissions
          passboolean :creator_enabled, :creator_editable
          embeds_one  :creator_flags, klass: "Ecoportal::API::V2::Page::PermissionFlags"
          passthrough :can

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

          def add_section(*secs)
            secs.each {|sec| section_ids.insert_one(sec.id)}
            self
          end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecoportal-api-v2-0.8.9 lib/ecoportal/api/v2/page/stage.rb