Module: Voteable

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

Instance Method Summary collapse

Instance Method Details

#negative_votesObject



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

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

#positive_votesObject



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

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

#total_valueObject



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

def total_value
  (positive_votes - negative_votes)
end