Module: SocialEngine::Voteable::InstanceMethods
- Defined in:
- app/models/social_engine/voteable.rb
Instance Method Summary collapse
- #downvote(options = {}) ⇒ Object
- #upvote(options = {}) ⇒ Object
- #vote_sum ⇒ Object
- #voteable? ⇒ Boolean
Instance Method Details
#downvote(options = {}) ⇒ Object
18 19 20 21 |
# File 'app/models/social_engine/voteable.rb', line 18 def downvote(={}) .reverse_merge!(:value=>-1) self.votes.create() end |
#upvote(options = {}) ⇒ Object
13 14 15 16 |
# File 'app/models/social_engine/voteable.rb', line 13 def upvote(={}) .reverse_merge!(:value=>1) self.votes.create() end |
#vote_sum ⇒ Object
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
9 10 11 |
# File 'app/models/social_engine/voteable.rb', line 9 def voteable? true end |