Class: Gluttonberg::Comment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gluttonberg/comment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blog_slugObject

Returns the value of attribute blog_slug.



18
19
20
# File 'app/models/gluttonberg/comment.rb', line 18

def blog_slug
  @blog_slug
end

#subscribe_to_commentsObject

Returns the value of attribute subscribe_to_comments.



18
19
20
# File 'app/models/gluttonberg/comment.rb', line 18

def subscribe_to_comments
  @subscribe_to_comments
end

Instance Method Details

#approved=(val) ⇒ Object



64
65
66
67
# File 'app/models/gluttonberg/comment.rb', line 64

def approved=(val)
  @approve_updated = !self.moderation_required && val && self.notification_sent_at.blank? #just got approved
  write_attribute(:approved, val)
end

#moderate(params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/gluttonberg/comment.rb', line 25

def moderate(params)
    if params == "approve"
      self.moderation_required = false
      self.approved = true
      self.save
    elsif params == "disapprove"
      self.moderation_required = false
      self.approved = false
      self.save
    else
      #error
    end
end

#user_idObject



39
40
41
# File 'app/models/gluttonberg/comment.rb', line 39

def user_id
  self.author_id
end

#user_id=(new_id) ⇒ Object



43
44
45
# File 'app/models/gluttonberg/comment.rb', line 43

def user_id=(new_id)
  self.author_id=new_id
end

#writer_emailObject

these are helper methods for comment.



48
49
50
51
52
53
54
# File 'app/models/gluttonberg/comment.rb', line 48

def writer_email
  if self.author_email
    self.author_email
  elsif author
    author.email
  end
end

#writer_nameObject



56
57
58
59
60
61
62
# File 'app/models/gluttonberg/comment.rb', line 56

def writer_name
  if self.author_name
    self.author_name
  elsif author
    author.name
  end
end