Sha256: 479bd6eb71740041b154282591ad57c86638986b9489f313c4baa1fae33d3345
Contents?: true
Size: 1.22 KB
Versions: 8
Compression:
Stored size: 1.22 KB
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 def published? self.id == 'published' end def as_current(&block) old_workspace = Workspace.current begin Workspace.current = self yield ensure Workspace.current = old_workspace end end end end
Version data entries
8 entries across 8 versions & 1 rubygems