Class: Fiona7::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/fiona7/workspace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Workspace

Returns a new instance of Workspace.



18
19
20
21
22
23
24
25
# File 'lib/fiona7/workspace.rb', line 18

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/fiona7/workspace.rb', line 6

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/fiona7/workspace.rb', line 6

def title
  @title
end

Class Method Details

.publishedObject



13
14
15
# File 'lib/fiona7/workspace.rb', line 13

def published
  self.new(:published)
end

.rtcObject



9
10
11
# File 'lib/fiona7/workspace.rb', line 9

def rtc
  self.new(:rtc)
end

Instance Method Details

#as_json(*options) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/fiona7/workspace.rb', line 56

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

#base_content_state_idObject



48
49
50
# File 'lib/fiona7/workspace.rb', line 48

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

#base_revision_idObject



44
45
46
# File 'lib/fiona7/workspace.rb', line 44

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

#content_state_idObject



40
41
42
# File 'lib/fiona7/workspace.rb', line 40

def content_state_id
  self.version_helper.content_state_id
end

#membershipsObject



52
53
54
# File 'lib/fiona7/workspace.rb', line 52

def memberships
  {}
end

#revision_idObject



36
37
38
# File 'lib/fiona7/workspace.rb', line 36

def revision_id
  self.version_helper.revision_id
end