Sha256: 6c6b192a127b9a3ad0d7bc0450eee009017b391ad2068dc5d4ef1f5bb14326e7

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

module Ecoportal
  module API
    class V2
      class Page < Common::Content::DoubleModel
        ALLOWED_KEYS  = [
          "id", "patch_ver", "name", "template_id",
          "base_tags", "tags",
          "time_zone", "created_at", "updated_at",
          "components", "sections", "stages",
          "permits", "mould_counter", "mould",
          "state", "task_priority",
          "votes_enabled", "upvotes", "downvotes",
          "force_errors", "subtags"
        ]

        passkey     :id
        passforced  :patch_ver, default: 1
        passthrough :name, :template_id
        passarray   :base_tags, :tags, order_matters: false
        passthrough :time_zone
        passdate    :created_at, :updated_at, read_only: true
        passthrough :can

        class_resolver :components_class, "Ecoportal::API::V2::Page::Components"
        class_resolver :sections_class,   "Ecoportal::API::V2::Page::Sections"
        class_resolver :stages_class,     "Ecoportal::API::V2::Page::Stages"

        embeds_many :components, enum_class: :components_class
        embeds_many :sections,   enum_class: :sections_class
        embeds_many :stages,     enum_class: :stages_class

        def as_update
          super.tap do |hash|
            unless !hash
              hash["data"].select! do |key, value|
                ALLOWED_KEYS.include?(key)
              end
              return nil if (hash["data"].keys - ["patch_ver"]).empty?
            end
          end
        end

      end
    end
  end
end

require 'ecoportal/api/v2/page/permission_flags'
require 'ecoportal/api/v2/page/permit'
require 'ecoportal/api/v2/page/component'
require 'ecoportal/api/v2/page/components'
require 'ecoportal/api/v2/page/section'
require 'ecoportal/api/v2/page/sections'
require 'ecoportal/api/v2/page/stage'
require 'ecoportal/api/v2/page/stages'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecoportal-api-v2-0.8.10 lib/ecoportal/api/v2/page.rb