Class: Comment

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Diaspora::Federated::Base, Diaspora::Guid, Diaspora::Likeable, Diaspora::Relayable, Diaspora::Taggable
Defined in:
app/models/comment.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Defined Under Namespace

Classes: Generator

Instance Method Summary collapse

Methods included from Diaspora::Likeable

included, #update_likes_counter

Methods included from Diaspora::Taggable

#build_tags, format_tags, included, #tag_strings

Methods included from Diaspora::Relayable

#after_receive, #author_is_not_ignored, included, #initialize_signatures, #parent_guid, #parent_guid=, #receive, #relayable?, #signature_valid?, #subscribers, #verify_parent_author_signature

Methods included from Diaspora::Encryptable

#sign_with_key, #signable_accessors, #signable_string, #verify_signature

Methods included from Diaspora::Guid

included, #set_guid

Methods included from Diaspora::Federated::Base

included

Instance Method Details

#diaspora_handleObject


52
53
54
# File 'app/models/comment.rb', line 52

def diaspora_handle
  self.author.diaspora_handle
end

#diaspora_handle=(nh) ⇒ Object


56
57
58
# File 'app/models/comment.rb', line 56

def diaspora_handle= nh
  self.author = Webfinger.new(nh).fetch
end

#messageObject


82
83
84
# File 'app/models/comment.rb', line 82

def message
  @message ||= Diaspora::MessageRenderer.new text
end

#notification_type(user, person) ⇒ Object


60
61
62
63
64
65
66
67
68
# File 'app/models/comment.rb', line 60

def notification_type(user, person)
  if self.post.author == user.person
    return Notifications::CommentOnPost
  elsif self.post.comments.where(:author_id => user.person.id) != [] && self.author_id != user.person.id
    return Notifications::AlsoCommented
  else
    return false
  end
end

#parentObject


74
75
76
# File 'app/models/comment.rb', line 74

def parent
  self.post
end

#parent=(parent) ⇒ Object


78
79
80
# File 'app/models/comment.rb', line 78

def parent= parent
  self.post = parent
end

#parent_classObject


70
71
72
# File 'app/models/comment.rb', line 70

def parent_class
  Post
end

#text=(text) ⇒ Object


86
87
88
# File 'app/models/comment.rb', line 86

def text= text
   self[:text] = text.to_s.strip #to_s if for nil, for whatever reason
end