Class: FileAttachment
- Inherits:
-
Flareshow::Resource
- Object
- Flareshow::Resource
- FileAttachment
- Extended by:
- Flareshow::Searchable
- Defined in:
- lib/file_attachment.rb
Class Method Summary collapse
-
.resource_key ⇒ Object
file attachments has a resource key of files for querying the server.
Instance Method Summary collapse
-
#download ⇒ Object
download the file contents.
-
#post ⇒ Object
post for this file.
-
#user ⇒ Object
user for this post.
Methods included from Flareshow::Searchable
Methods inherited from Flareshow::Resource
#cache, cache_response, #changes, create, default_params, #destroy, #destroyed?, find, first, #get, get_from_cache, #id, #initialize, list_cache, #method_missing, #method_name, #refresh, #resource_key, #save, #set, store, #update
Constructor Details
This class inherits a constructor from Flareshow::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Flareshow::Resource
Class Method Details
.resource_key ⇒ Object
file attachments has a resource key of files for querying the server
13 14 15 |
# File 'lib/file_attachment.rb', line 13 def resource_key "files" end |
Instance Method Details
#download ⇒ Object
download the file contents
19 20 21 22 23 24 25 26 |
# File 'lib/file_attachment.rb', line 19 def download url = self.url unless url.match(/http/) url = "http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}#{url}" end Flareshow::Util.log_info("getting #{url}") Flareshow::Service.http_get(url) end |
#post ⇒ Object
post for this file
29 30 31 32 33 34 35 |
# File 'lib/file_attachment.rb', line 29 def post return false unless post_id post = Post.get_from_cache(post_id) post ||= Comment.get_from_cache(post_id) post ||= Post.find({:id => post_id}) post ||= Comment.find({:id => post_id}) end |