voteable_tommotaylor 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_tommotaylor.rb +23 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d572d6752fe29b94661800578f820bd77393f76b
4
+ data.tar.gz: d9162f89ca50f38cd2f7e12e99c500dfa1fdca3d
5
+ SHA512:
6
+ metadata.gz: 8e5662dba81bed974a9b4117aed51f3adfbb3b6262785d58eed03688a781392e1a945b72097d2927ff55436a90691296882b903f946853dd71817a96d98945c7
7
+ data.tar.gz: 7b7c4afb2d0ee99ff7619f7147806a0bb22502461356ec2daf0532f580bf561a276c7171f2d54739da7ccff4b409d43208cf740cdafd1abd39d05b3fc2f9125b
@@ -0,0 +1,23 @@
1
+ module Voteable
2
+
3
+
4
+ included do
5
+ has_many :votes, as: :voteable
6
+ end
7
+
8
+
9
+
10
+ def total_votes
11
+ self.up_votes - self.down_votes
12
+ end
13
+
14
+ def up_votes
15
+ self.votes.where(vote: true).size
16
+ end
17
+
18
+ def down_votes
19
+ self.votes.where(vote: false).size
20
+ end
21
+
22
+ end
23
+
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_tommotaylor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Taylor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: voteable gem created as part of Tealeaf Academy Course 2
14
+ email: tommotaylor@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable_tommotaylor.rb
20
+ homepage: http://tom-taylor.info
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.2.2
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: gem to allow for voteable functionality
43
+ test_files: []