Sha256: 42fd47e449cc4db1fbbc2e7fee8b80a49cdfbb1ce217591d82701883107d76d2
Contents?: true
Size: 1.04 KB
Versions: 7
Compression:
Stored size: 1.04 KB
Contents
module RailsConnector class Workspace extend ActiveModel::Naming include 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 title @workspace_data.title end def data @workspace_data 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
7 entries across 7 versions & 1 rubygems