Class: Post
- Inherits:
-
Flareshow::Base
- Object
- Flareshow::Base
- Post
- Defined in:
- lib/post.rb
Instance Method Summary collapse
-
#build_comment(attributes = {}) ⇒ Object
build a new comment but don’t immediately persist it.
- #build_file(file_path) ⇒ Object
-
#create_comment(attributes = {}) ⇒ Object
create a new comment on the post.
-
#create_file(file_path) ⇒ Object
upload a file to a post.
-
#permalink(mobile = false) ⇒ Object
permalink to this post.
Methods inherited from Flareshow::Base
all, api_endpoint, assimilate_resources, auth_endpoint, authenticate, #changes, commit, create, #destroy, #destroyed?, dispatch, find, first, get, #get, handle_response, http_get, #id, #initialize, list, #method_missing, #method_name, post, process_response, query, #refresh, #save, server_defined?, #set, store, #update
Constructor Details
This class inherits a constructor from Flareshow::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Flareshow::Base
Instance Method Details
#build_comment(attributes = {}) ⇒ Object
build a new comment but don’t immediately persist it
13 14 15 16 17 |
# File 'lib/post.rb', line 13 def build_comment(attributes={}) c = Comment.new(attributes) c.post_id = self.id c end |
#build_file(file_path) ⇒ Object
25 26 27 28 |
# File 'lib/post.rb', line 25 def build_file(file_path) self.files ||= [] self.files += [{"part_id" => "file_#{UUID.generate}", "file_path" => file_path}] end |
#create_comment(attributes = {}) ⇒ Object
create a new comment on the post
20 21 22 23 |
# File 'lib/post.rb', line 20 def create_comment(attributes={}) c = build_comment(attributes) c.save end |
#create_file(file_path) ⇒ Object
upload a file to a post
31 32 33 34 35 36 |
# File 'lib/post.rb', line 31 def create_file(file_path) self.files = [] self.build_file(file_path) self.save self.files = nil end |
#permalink(mobile = false) ⇒ Object
permalink to this post
4 5 6 7 8 9 10 |
# File 'lib/post.rb', line 4 def permalink(mobile=false) if mobile "http://#{Flareshow::Base.server.host}/#{Flareshow::Base.server.domain}/shareflow/mobile/post/#{id}" else "http://#{Flareshow::Base.server.host}/#{Flareshow::Base.server.domain}/shareflow/p/#{id}" end end |