Module: VoteableTj::InstanceMethods

Defined in:
lib/voteable-tj.rb

Instance Method Summary collapse

Instance Method Details

#already_voted_on?(obj) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/voteable-tj.rb', line 25

def already_voted_on?(obj)
  self.votes.where(voteable: obj).size > 0
end

#down_votesObject



21
22
23
# File 'lib/voteable-tj.rb', line 21

def down_votes
  self.votes.where(vote: false).size
end

#total_votesObject



13
14
15
# File 'lib/voteable-tj.rb', line 13

def total_votes
  self.votes.where(vote: true).size - self.votes.where(vote: false).size
end

#up_votesObject



17
18
19
# File 'lib/voteable-tj.rb', line 17

def up_votes
  self.votes.where(vote: true).size
end