Class: Inbox::Thread
Instance Attribute Summary
Attributes inherited from RestfulModel
#raw_json
Instance Method Summary
collapse
time_attr_accessor
#mark_as_read!, #mark_as_unread!, #star!, #unstar!, #update_param!
#==, collection_name, #destroy, #initialize, #save!, #update, #url
Methods included from Parameters
included, #parameters
Instance Method Details
#as_json(options = {}) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/api_thread.rb', line 52
def as_json(options = {})
hash = {}
if not @unread.nil?
hash["unread"] = @unread
end
if not @starred.nil?
hash["starred"] = @starred
end
if not @labels.nil? and @labels != []
hash["label_ids"] = @labels.map do |label|
label.id
end
end
if not @folder.nil?
hash["folder_id"] = @folder.id
end
hash
end
|
#inflate(json) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/api_thread.rb', line 24
def inflate(json)
super
@labels ||= []
@folder ||= nil
@labels.map! do |label_json|
label = Label.new(@_api)
label.inflate(label_json)
label
end
if not folder.nil? and folder.is_a?(Hash)
folder = Folder.new(@_api)
folder.inflate(@folder)
@folder = folder
end
end
|