Sha256: 1f70c4f2875f30a71c5d11a308a5df9f5afca14bb64bc06f6f0823f7c4d4a570

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

require 'fiona7/version_helper'
require 'fiona7/assert'

module Fiona7
  class Workspace
    attr_reader :id, :title

    class << self
     def rtc
        self.new(:rtc)
      end
      
      def published
        self.new(:published)
      end
    end

    def initialize(id)
      @id = id.to_sym
      Assert.constraint(
        @id == :rtc || @id == :published,
        "Only published and rtc workspaces are possible"
      )
      @version_helper = VersionHelper.new(@id)
    end

    def title
      if self.id == :rtc

        self.localized_title
      else
        nil
      end
    end

    def revision_id
      self.version_helper.revision_id
    end

    def content_state_id
      self.version_helper.content_state_id
    end

    def base_revision_id
      self.version_helper.base_revision_id if self.id == :rtc
    end

    def base_content_state_id
      self.version_helper.base_content_state_id if self.id == :rtc
    end

    def memberships
      {}
    end

    def as_json(*options)
      r = {
        id: self.id,
        title: self.title,
        revision_id: self.revision_id,
        content_state_id: self.content_state_id,
        outdated: false,
        auto_update: (self.id == :rtc),
        memberships: self.memberships
      }

      r.merge!({
        base_revision_id: self.base_revision_id,
        base_content_state_id: self.base_content_state_id
      }) if self.id == :rtc

      r.as_json(*options)
    end


    protected
    attr_reader :version_helper
    def localized_title
      locale = Scrivito::Configuration.ui_locale || I18n.locale
      I18n.t(:"fiona7.workspace.rtc", locale: locale)
    rescue
      'Arbeitskopie '
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/workspace.rb
infopark_fiona7-1.6.1.1.1 lib/fiona7/workspace.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/workspace.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/workspace.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/workspace.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/workspace.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/workspace.rb
infopark_fiona7-1.5.5.3.1 lib/fiona7/workspace.rb
infopark_fiona7-1.5.4.3.0 lib/fiona7/workspace.rb