Sha256: d7252ee0f652a6e297f3d177920d6d9921fe061e3676ff8a727aab1f8656b561

Contents?: true

Size: 964 Bytes

Versions: 80

Compression:

Stored size: 964 Bytes

Contents

module Scrivito
  module Migrations
    class CmsBackend
      def read
        if obj = find_migration_store_obj
          obj.data_from_cms.value_of('versions')
        else
          ''
        end
      end

      def save(value)
        CmsRestApi.put(endpoint("objs/#{migration_store_obj.id}"),
          obj: {versions: ['string', value]})

        Workspace.current.reload
      end

      private

      def create
        CmsRestApi.post(endpoint('objs'),
          obj: {_path: path, _obj_class: 'MigrationStore', versions: ['string', '']})

        Workspace.current.reload
      end

      def migration_store_obj
        create unless find_migration_store_obj
        find_migration_store_obj
      end

      def find_migration_store_obj
        Obj.find_by_path(path)
      end

      def path
        '/_internal/migration-store'
      end

      def endpoint(path)
        "workspaces/#{Workspace.current.id}/#{path}"
      end
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
scrivito_sdk-1.0.0.rc2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-1.0.0.rc1 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.90.0 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.90.0.rc3 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.90.0.rc2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.90.0.rc1 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.70.2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.71.2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.71.1 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.70.1 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.71.0 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.71.0.rc2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.71.0.rc1 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.70.0 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.70.0.rc3 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.70.0.rc2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.70.0.rc1 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.66.0 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.66.0.rc2 lib/scrivito/migrations/cms_backend.rb
scrivito_sdk-0.66.0.rc1 lib/scrivito/migrations/cms_backend.rb