Module: SocialEngine::Voteable::InstanceMethods

Defined in:
app/models/social_engine/voteable.rb

Instance Method Summary collapse

Instance Method Details

#downvote(options = {}) ⇒ Object



18
19
20
21
# File 'app/models/social_engine/voteable.rb', line 18

def downvote(options={})
  options.reverse_merge!(:value=>-1)
  self.votes.create(options)
end

#upvote(options = {}) ⇒ Object



13
14
15
16
# File 'app/models/social_engine/voteable.rb', line 13

def upvote(options={})
  options.reverse_merge!(:value=>1)
  self.votes.create(options)
end

#vote_sumObject



23
24
25
# File 'app/models/social_engine/voteable.rb', line 23

def vote_sum
  self.votes.inject(0){|sum,vote| sum = sum + vote.value}
end

#voteable?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/social_engine/voteable.rb', line 9

def voteable?
  true
end