voteable_buddy 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/voteable_buddy.rb +19 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5604211c45a4fe6d8535aec4062afd524a6dbc31
4
+ data.tar.gz: c00d19f23fc32739aaa61c431bb190889e673948
5
+ SHA512:
6
+ metadata.gz: 561cfb5ed2f02ce8e653a31bf464f4a887ad66baefa6516446e7ecca25b46214f7d2ed50915eceffbb51dd8cb9e640973d80e30c46b767511d3f05b8b8d6bfa8
7
+ data.tar.gz: d5ae135e1d854695fe9c99ea4b9e39526b94dedb1d383067340f3ab7164e5f9e57d25d55ac465019ab9942ce91bb8903b873ce854bef3c223eb419492f381a27
@@ -0,0 +1,19 @@
1
+ module Voteable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_many :votes, as: :voteable
6
+ end
7
+
8
+ def total_votes
9
+ self.up_votes - self.down_votes
10
+ end
11
+
12
+ def up_votes
13
+ self.votes.where(vote: true).size
14
+ end
15
+
16
+ def down_votes
17
+ self.votes.where(vote: false).size
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_buddy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Larry Lumbreras
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This is a gem for voting.
14
+ email: llumbreras@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable_buddy.rb
20
+ homepage: https://github.com/llumbreras/voteable-buddy
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.1.11
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A voting gem.
44
+ test_files: []