votes_count 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/votes_count.rb +19 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0e7357934cd92877c9b1a672c4ba14540fc7d98d
4
+ data.tar.gz: 2cab8706b628a8d056bb83bd0db091e01c1cf135
5
+ SHA512:
6
+ metadata.gz: b634ee43a12ef70576987916eef93b099506c71c4c6a214668ec2f174b176506318a4b12a249f15701076b128b7280d54958c283c82c4359a6cb3df510a7201d
7
+ data.tar.gz: 44012a6d55f2165969e63051dd68b1ece5ffdc4bf8cebfd909910e956ccc7330915c5ed1667addeacc98e42e9934f52c3c5e331bead4f9eacebae890b93b8648
@@ -0,0 +1,19 @@
1
+ module VotesCount
2
+ extend ActiveSupport::Concern #TODO
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,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: votes_count
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Wu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple votes count gem
14
+ email: wuqi0509@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/votes_count.rb
20
+ homepage: https://github.com/springwq/votes_count
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.4.5
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Count your votes
44
+ test_files: []
45
+ has_rdoc: