Module: VoteableHolden

Extended by:
ActiveSupport::Concern
Defined in:
lib/voteable_holden.rb

Instance Method Summary collapse

Instance Method Details

#display_votesObject



8
9
10
# File 'lib/voteable_holden.rb', line 8

def display_votes
  total_votes == 1 || total_votes == -1 ? "#{total_votes} vote" : "#{total_votes} votes"
end

#down_votesObject



20
21
22
# File 'lib/voteable_holden.rb', line 20

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

#total_votesObject



12
13
14
# File 'lib/voteable_holden.rb', line 12

def total_votes
  up_votes - down_votes
end

#up_votesObject



16
17
18
# File 'lib/voteable_holden.rb', line 16

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