Sha256: 6f52a0348a16f02727d04cf0c3e15c4dd4406bb1d1352aa0cd1f7648347f02d7

Contents?: true

Size: 1.77 KB

Versions: 30

Compression:

Stored size: 1.77 KB

Contents

module Scrivito
  class WorkspaceData
    private_class_method def self.data_attr_reader(attr_name)
      define_method(attr_name) { @data[attr_name.to_s] }
    end

    data_attr_reader :id
    data_attr_reader :title
    data_attr_reader :memberships
    data_attr_reader :revision_id
    data_attr_reader :base_revision_id

    def content_state_id
      @data["content_state_id"] or raise InternalError
    end

    def content_state_id?
      @data["content_state_id"].present?
    end

    def auto_update?
      @data["auto_update"]
    end

    def base_content_state_id
      @data["base_content_state_id"] or raise InternalError
    end

    def base_content_state_id?
      @data["base_content_state_id"].present?
    end

    def initialize(data)
      raise InternalError unless Hash === data && data["id"].present?
      @data = data
      assert_no_obj_classes
    end

    private

    def assert_no_obj_classes
      if @data['uses_obj_classes']
        raise ScrivitoError, "The working copy titled #{title} has ObjClasses, which is no longer "\
          "supported. Please use version 0.60.0 to have CMS-based ObjClasses removed from your "\
          "working copies. See https://scrivito.com/scrivito/obj-class-migration for a "\
          "detailed guide on upgrading."
      end
    end

    def to_hash
      base_csid = base_content_state_id? ? base_content_state_id : nil

      {
        'id'                    => id,
        'revision_id'           => revision_id,
        'title'                 => title,
        'content_state_id'      => content_state_id,
        'base_revision_id'      => base_revision_id,
        'base_content_state_id' => base_csid,
        'memberships'           => memberships,
        'auto_update'           => auto_update?,
      }
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
scrivito_sdk-1.18.0 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.18.0.rc1 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.17.0 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.17.0.rc3 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.17.0.rc2 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.17.0.rc1 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.16.0 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.16.0.rc2 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.16.0.rc1 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.15.0 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.15.0.rc2 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.15.0.rc1 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.14.0 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.14.0.rc3 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.14.0.rc2 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.14.0.rc1 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.13.0 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.13.0.rc2 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.13.0.rc1 app/cms/scrivito/workspace_data.rb
scrivito_sdk-1.12.0 app/cms/scrivito/workspace_data.rb