Class: Confluence::Page
Overview
Exposes a vaguely ActiveRecord-like interface for dealing with Confluence::Pages in Confluence.
Constant Summary
collapse
- DEFAULT_SPACE =
"encore"
Instance Attribute Summary
#attributes, #confluence, #encore
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #[], #[]=, #as_boolean, #as_datetime, #as_int, #as_string, confluence, connector, connector=, #destroy, encore, find, #id, #method_missing, #reload, #save
Constructor Details
#initialize(data_object = nil) ⇒ Page
Returns a new instance of Page.
25
26
27
28
|
# File 'lib/confluence/page.rb', line 25
def initialize(data_object = nil)
super
end
|
Class Method Details
.find_by_name(name, space = DEFAULT_SPACE) ⇒ Object
class methods ###########################################################
102
103
104
|
# File 'lib/confluence/page.rb', line 102
def self.find_by_name(name, space = DEFAULT_SPACE)
find_by_title(name, space)
end
|
.find_by_title(title, space = DEFAULT_SPACE) ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/confluence/page.rb', line 106
def self.find_by_title(title, space = DEFAULT_SPACE)
begin
r = confluence.getPage(space, title)
rescue Confluence::RemoteException => e
if e.message =~ /does not exist/
return nil
else
raise e
end
end
self.new(r)
end
|
Instance Method Details
#before_save ⇒ Object
callbacks ###############################################################
94
95
96
|
# File 'lib/confluence/page.rb', line 94
def before_save
raise "Cannot save this page because it has no title and/or space." unless self.title and self.space
end
|
#content=(new_content) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/confluence/page.rb', line 38
def content=(new_content)
old_metadata = self.metadata.entries if self.content
super
self.metadata.merge! old_metadata if old_metadata
end
|
#edit_group ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/confluence/page.rb', line 66
def edit_group
perm = get_permissions
return nil if perm.nil? or perm.empty?
perm.each do |p|
return p['lockedBy'] if p['lockType'] == 'Edit'
end
return nil
end
|
#edit_group=(group) ⇒ Object
62
63
64
|
# File 'lib/confluence/page.rb', line 62
def edit_group=(group)
encore.setPageEditGroup(self.title, group)
end
|
#get_permissions ⇒ Object
88
89
90
|
# File 'lib/confluence/page.rb', line 88
def get_permissions
confluence.getPagePermissions(self.id.to_s)
end
|
#load_from_object(data_object) ⇒ Object
45
46
47
48
|
# File 'lib/confluence/page.rb', line 45
def load_from_object(data_object)
super
self.modifier = self.confluence_username unless self.attributes.include? :modifier
end
|
50
51
52
|
# File 'lib/confluence/page.rb', line 50
def metadata
Confluence::Metadata.new(self)
end
|
#name ⇒ Object
34
35
36
|
# File 'lib/confluence/page.rb', line 34
def name
self.title
end
|
#name=(new_name) ⇒ Object
30
31
32
|
# File 'lib/confluence/page.rb', line 30
def name=(new_name)
self.title = new_name
end
|
#parent ⇒ Object
54
55
56
|
# File 'lib/confluence/page.rb', line 54
def parent
self.class.find(self.parentId)
end
|
#to_s ⇒ Object
58
59
60
|
# File 'lib/confluence/page.rb', line 58
def to_s
self.title
end
|
#view_group ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/confluence/page.rb', line 79
def view_group
perm = get_permissions
return nil if perm.nil? or perm.empty?
perm.each do |p|
return p['lockedBy'] if p['lockType'] == 'View'
end
return nil
end
|
#view_group=(group) ⇒ Object
75
76
77
|
# File 'lib/confluence/page.rb', line 75
def view_group=(group)
encore.setPageViewGroup(self.title, group)
end
|