Class: Inbox::File

Inherits:
RestfulModel show all
Defined in:
lib/file.rb

Instance Attribute Summary collapse

Attributes inherited from RestfulModel

#created_at, #id, #namespace_id

Instance Method Summary collapse

Methods inherited from RestfulModel

#==, #as_json, collection_name, #destroy, #initialize, #update, #url

Constructor Details

This class inherits a constructor from Inbox::RestfulModel

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



8
9
10
# File 'lib/file.rb', line 8

def content_type
  @content_type
end

#fileObject

For uploading the file



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

def file
  @file
end

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/file.rb', line 7

def filename
  @filename
end

#is_embeddedObject

Returns the value of attribute is_embedded.



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

def is_embedded
  @is_embedded
end

#message_idObject

Returns the value of attribute message_id.



10
11
12
# File 'lib/file.rb', line 10

def message_id
  @message_id
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

Instance Method Details

#inflate(json) ⇒ Object



15
16
17
18
# File 'lib/file.rb', line 15

def inflate(json)
  super
  content_type = json["content-type"] if json["content-type"]
end

#save!Object



20
21
22
23
24
25
26
27
# File 'lib/file.rb', line 20

def save!
  ::RestClient.post(url, {:file => @file}) do |response, request, result|
    json = Inbox.interpret_response(result, response, :expected_class => Object)
    json = json[0] if (json.class == Array)
    inflate(json)
  end
  self
end