Class: Comment

Inherits:
Flareshow::Resource show all
Extended by:
Flareshow::Searchable
Defined in:
lib/comment.rb

Instance Method Summary collapse

Methods included from Flareshow::Searchable

search

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, 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

Instance Method Details

#contentObject



36
37
38
# File 'lib/comment.rb', line 36

def content
  Nokogiri::HTML::Document.new.fragment(get("content")).to_s
end

#filesObject

persisted files for this post



31
32
33
34
# File 'lib/comment.rb', line 31

def files
  cached = FileAttachment.list_cache
  files = cached.select{|f|f.post_id == id}
end

permalink to this comment



9
10
11
12
13
14
15
# File 'lib/comment.rb', line 9

def permalink(mobile=false)
  if mobile
    "http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}/shareflow/mobile/post/#{reply_to}"
  else
    "http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}/shareflow/p/#{reply_to}?comment_id#{id}"
  end
end

#postObject

get the post for this comment



18
19
20
21
# File 'lib/comment.rb', line 18

def post
  post = Post.get_from_cache(reply_to)
  post || Post.first(:id => reply_to)
end

#userObject

user for this post



24
25
26
27
28
# File 'lib/comment.rb', line 24

def user
  return User.current unless user_id
  user = User.get_from_cache(user_id)
  user || User.first({:id => user_id})
end