voteable_sueanne 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/voteable_sueanne.rb +20 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e7e819c659ac3625fe780bccdd08fad4e0f87e3
4
+ data.tar.gz: f1fcbe86c1cde75151acffe61a70156d6cc7b36d
5
+ SHA512:
6
+ metadata.gz: 29d035e2a184fe530114603a95230946c3f87bfaf12c5ec6667ebb619470e3ac6c3cf1320183f3288fe3acea7b3d679744dc19a55d6b4b96f54a7078d9b3701d
7
+ data.tar.gz: b22bdc20541b37321a247359e880f826dbdc92fb36c7bbd174d172a7aadb91013ac670119cfe08f18ab1cc5024ff864d5121db76ff3e3fcd715c61425a5a865e
@@ -0,0 +1,20 @@
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
+
20
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_sueanne
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sue Anne
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: a gem that makes voting easier. created as part of the Tealeaf ruby on
14
+ rails course. votes up and down and also count total of votes
15
+ email: sueanneteo@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/voteable_sueanne.rb
21
+ homepage: http://github.com
22
+ licenses: []
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: []