Class: Inkwell::Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Inkwell::Comment
- Defined in:
- app/models/inkwell/comment.rb
Instance Attribute Summary collapse
-
#from_sources_in_timeline ⇒ Object
Returns the value of attribute from_sources_in_timeline.
-
#is_favorited ⇒ Object
Returns the value of attribute is_favorited.
-
#is_reblog_in_blogline ⇒ Object
Returns the value of attribute is_reblog_in_blogline.
-
#is_reblogged ⇒ Object
Returns the value of attribute is_reblogged.
-
#item_id_in_line ⇒ Object
Returns the value of attribute item_id_in_line.
Instance Method Summary collapse
- #comment_count ⇒ Object
- #commentline(options = {}) ⇒ Object
- #favorite_count ⇒ Object
- #reblog_count ⇒ Object
Methods included from Common
#category_class, #check_post, #check_user, #community_class, #community_id_attr, #get_class_for_item_type, #get_item_type, #get_owner_type, #post_class, #user_class, #user_id_attr
Instance Attribute Details
#from_sources_in_timeline ⇒ Object
Returns the value of attribute from_sources_in_timeline.
11 12 13 |
# File 'app/models/inkwell/comment.rb', line 11 def from_sources_in_timeline @from_sources_in_timeline end |
#is_favorited ⇒ Object
Returns the value of attribute is_favorited.
8 9 10 |
# File 'app/models/inkwell/comment.rb', line 8 def is_favorited @is_favorited end |
#is_reblog_in_blogline ⇒ Object
Returns the value of attribute is_reblog_in_blogline.
10 11 12 |
# File 'app/models/inkwell/comment.rb', line 10 def is_reblog_in_blogline @is_reblog_in_blogline end |
#is_reblogged ⇒ Object
Returns the value of attribute is_reblogged.
7 8 9 |
# File 'app/models/inkwell/comment.rb', line 7 def is_reblogged @is_reblogged end |
#item_id_in_line ⇒ Object
Returns the value of attribute item_id_in_line.
9 10 11 |
# File 'app/models/inkwell/comment.rb', line 9 def item_id_in_line @item_id_in_line end |
Instance Method Details
#comment_count ⇒ Object
49 50 51 52 |
# File 'app/models/inkwell/comment.rb', line 49 def comment_count users_ids_who_comment_it = ActiveSupport::JSON.decode self.users_ids_who_comment_it users_ids_who_comment_it.size end |
#commentline(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/inkwell/comment.rb', line 21 def commentline( = {}) .symbolize_keys! last_shown_comment_id = [:last_shown_comment_id] limit = [:limit] || 10 for_user = [:for_user] if for_user user_class = Object.const_get ::Inkwell::Engine::config.user_table.to_s.singularize.capitalize raise "for_user param should be a #{user_class.to_s} but it is #{for_user.class.to_s}" unless for_user.class == user_class end users_ids_who_comment_it = ActiveSupport::JSON.decode self.users_ids_who_comment_it if last_shown_comment_id last_shown_comment_index = users_ids_who_comment_it.index{|rec| rec["comment_id"] == last_shown_comment_id} users_ids_who_comment_it = users_ids_who_comment_it[0..last_shown_comment_index-1] end result_comments_info = users_ids_who_comment_it.last(limit) result = [] result_comments_info.each do |comment_info| comment = ::Inkwell::Comment.find comment_info["comment_id"] if for_user comment.is_reblogged = for_user.reblog? comment comment.is_favorited = for_user.favorite? comment end result << comment end result end |
#favorite_count ⇒ Object
54 55 56 57 |
# File 'app/models/inkwell/comment.rb', line 54 def favorite_count users_ids_who_favorite_it = ActiveSupport::JSON.decode self.users_ids_who_favorite_it users_ids_who_favorite_it.size end |
#reblog_count ⇒ Object
59 60 61 62 |
# File 'app/models/inkwell/comment.rb', line 59 def reblog_count users_ids_who_reblog_it = ActiveSupport::JSON.decode self.users_ids_who_reblog_it users_ids_who_reblog_it.size end |