Class: SakaiInfo::Content
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ModProps
included
Methods inherited from SakaiObject
#dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Instance Attribute Details
#parent_id ⇒ Object
Returns the value of attribute parent_id.
14
15
16
|
# File 'lib/sakai-info/content.rb', line 14
def parent_id
@parent_id
end
|
Class Method Details
.all_serializations ⇒ Object
144
145
146
147
148
149
150
151
152
|
# File 'lib/sakai-info/content.rb', line 144
def self.all_serializations
[
:default,
:children,
:realm,
:properties,
:mod
]
end
|
Instance Method Details
#binary_entity ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/sakai-info/content.rb', line 50
def binary_entity
if @binary_entity.nil?
@binary_entity = ContentBinaryEntity.new(@dbrow[:binary_entity])
@dbrow[:_binary_entity_created_by] = @binary_entity["CHEF:creator"]
@dbrow[:_binary_entity_modified_by] = @binary_entity["CHEF:modifiedby"]
@dbrow[:_binary_entity_created_at] =
Util.format_entity_date(@binary_entity["DAV:creationdate"])
@dbrow[:_binary_entity_modified_at] =
Util.format_entity_date(@binary_entity["DAV:getlastmodified"])
end
@binary_entity
end
|
#child_summary_serialization ⇒ Object
108
109
110
111
112
113
|
# File 'lib/sakai-info/content.rb', line 108
def child_summary_serialization
{
"id" => self.id.gsub(/^#{self.parent_id}/,""),
"size" => self.size_on_disk,
}
end
|
#default_serialization ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/sakai-info/content.rb', line 65
def default_serialization
{
"id" => self.id,
"parent" => self.parent_id,
"size_on_disk" => self.size_on_disk
}
end
|
#effective_realm ⇒ Object
94
95
96
|
# File 'lib/sakai-info/content.rb', line 94
def effective_realm
self.realm || (parent.nil? ? nil : parent.effective_realm)
end
|
#mod_details_serialization ⇒ Object
139
140
141
142
|
# File 'lib/sakai-info/content.rb', line 139
def mod_details_serialization
self.binary_entity
self.original_mod_details_serialization
end
|
#mod_serialization ⇒ Object
134
135
136
137
|
# File 'lib/sakai-info/content.rb', line 134
def mod_serialization
self.binary_entity
self.original_mod_serialization
end
|
#original_mod_details_serialization ⇒ Object
132
|
# File 'lib/sakai-info/content.rb', line 132
alias :original_mod_details_serialization :mod_details_serialization
|
#original_mod_serialization ⇒ Object
ensure @binary_entity has been parsed before returning mod info
131
|
# File 'lib/sakai-info/content.rb', line 131
alias :original_mod_serialization :mod_serialization
|
#parent ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/sakai-info/content.rb', line 38
def parent
if @parent_id.nil?
nil
else
@parent ||= ContentCollection.find(@parent_id)
end
end
|
#properties_serialization ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/sakai-info/content.rb', line 115
def properties_serialization
result = self.binary_entity.to_hash
if result["groups"] == []
result.delete("groups")
end
result.keys.each do |key|
if result[key].nil? or result[key] == ""
result.delete(key)
end
end
{
"properties" => result
}
end
|
#realm ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/sakai-info/content.rb', line 81
def realm
if @realm_is_nil
nil
else
begin
@realm ||= AuthzRealm.find_by_name("/content#{@id}")
rescue ObjectNotFoundException
@realm_is_nil = true
nil
end
end
end
|
#realm_serialization ⇒ Object
98
99
100
101
102
103
104
105
106
|
# File 'lib/sakai-info/content.rb', line 98
def realm_serialization
if self.effective_realm.nil?
{}
else
{
"effective_realm" => self.effective_realm.name,
}
end
end
|
#size_on_disk ⇒ Object
46
47
48
|
# File 'lib/sakai-info/content.rb', line 46
def size_on_disk
0
end
|
#summary_serialization ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/sakai-info/content.rb', line 73
def summary_serialization
{
"id" => self.id,
"parent" => self.parent_id,
"size_on_disk" => self.size_on_disk
}
end
|