Sha256: 75f86d53df54ab1b0234ac102b0b79f17a485fd6bfabf6829ba624e39f91873f

Contents?: true

Size: 1017 Bytes

Versions: 4

Compression:

Stored size: 1017 Bytes

Contents

module RailsConnector

class Workspace
  extend ActiveModel::Naming
  include Kvom::ModelIdentity

  def self.current=(workspace_or_proc)
    @current = workspace_or_proc
  end

  def self.current
    if @current.respond_to? :call
      @current = @current.call
    else
      @current || default
    end
  end

  def self.default
    find("published")
  end

  def self.find(id)
    if workspace_data = CmsBackend.find_workspace_data_by_id(id)
      Workspace.new workspace_data
    else
      raise ResourceNotFound, "Could not find #{self} with id #{id}"
    end
  end

  def initialize(workspace_data)
    @workspace_data = workspace_data
  end

  def id
    @workspace_data.id
  end

  def revision_id
    @workspace_data.revision_id
  end

  def data
    @workspace_data
  end

  # only available with direct access to dynamo
  def revision
    @workspace_data.revision
  end

  # only available with direct access to dynamo
  def content_cache_id=(id)
    @workspace_data.content_cache_id = id
  end

end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.0.498.46559598 lib/rails_connector/workspace.rb
infopark_cloud_connector-6.8.0.480.261594408 lib/rails_connector/workspace.rb
infopark_cloud_connector-6.8.0.444.171626367 lib/rails_connector/workspace.rb
infopark_cloud_connector-6.8.0.406.131718077 lib/rails_connector/workspace.rb