Class: Inbox::Message
Direct Known Subclasses
Draft
Instance Method Summary
collapse
#==, collection_name, #destroy, #initialize, #save!, #update, #url
#time_attr_accessor
Methods included from Parameters
included, #parameters
Instance Method Details
#as_json(options = {}) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/message.rb', line 44
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["labels"] = @labels.map do |label|
label.id
end
end
if not @folder.nil?
hash["folder"] = @folder.id
end
hash
end
|
#inflate(json) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/message.rb', line 21
def inflate(json)
super
@to ||= []
@cc ||= []
@bcc ||= []
@labels ||= []
@folder ||= nil
@labels.map! do |label_json|
label = Label.new(@_api)
label.inflate(label_json)
label
end
if not folder.nil?
folder = Folder.new(@_api)
folder.inflate(@folder)
@folder = folder
end
end
|
#raw ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/message.rb', line 74
def raw
model = nil
collection = RestfulModelCollection.new(Message, @_api, {:message_id=>@id})
RestClient.get("#{collection.url}/#{id}/", :accept => 'message/rfc822'){ |response,request,result|
response
}
end
|