count_votes_jun 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/count_votes_jun.rb +19 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b135c9e3cecaeb2f0d41337d040b2720ba46b31
4
+ data.tar.gz: 50a4d1c355ed319b98ae770b8c7621801d308182
5
+ SHA512:
6
+ metadata.gz: 244a757d252897a069b945f6f6fcb94ea7a205301c846d6066b0704236e7db9289dcb25bccb82d69d5f6308ad803b41b0c6680b082ca7a98940bbcec59d8a9b6
7
+ data.tar.gz: 9c6ffdf24432a602ace01ee51a4d306a460df98a2a9083bed0be0a0286a494a07ad129077976460e6e8e837daa4822e849014309ef807acda0a1536cc2bff77d
@@ -0,0 +1,19 @@
1
+ module CountVotes
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: count_votes_jun
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sam Hains
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple hello world gem
14
+ email: sdh@eml.cc
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/count_votes_jun.rb
20
+ homepage: http://rubygems.org/gems/count_votes_jun
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.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Hola!
44
+ test_files: []