voteable_nancy 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_nancy.rb +20 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 89c7ed4895727764afd4b430e92e81faa612c8351f4051c96cb792431621ef16
4
+ data.tar.gz: 1a2d075fe70e58681938a037eade0e4fc3f0a3d7e043177f9f89eb62cfda5460
5
+ SHA512:
6
+ metadata.gz: 1b642bc0f92512641ac2c5799a1d236bf84024d65299fd920de8c9608f810c52d78ffe723b64ad0d73b6a86764e7ac95c746b8d1f6c0d2b5b8986c1968801fa6
7
+ data.tar.gz: 955a91a63fda6401448740c17743ee45c867ad53ef50d66cbc221d82901d7ea713a1a4acdb632520da1201a3814719ba96ed5f3c2873d7d6191f3b48b9125dfa
@@ -0,0 +1,20 @@
1
+ module Voteable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # run this at inclusion time
6
+ has_many :votes, as: :voteable
7
+ end
8
+
9
+ def total_votes
10
+ self.upvotes - self.downvotes
11
+ end
12
+
13
+ def upvotes
14
+ self.votes.where(vote: true).size
15
+ end
16
+
17
+ def downvotes
18
+ self.votes.where(vote: false).size
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_nancy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nancy Trinh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: My voting gem.
14
+ email:
15
+ - nancy@ls.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/voteable_nancy.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
+ rubygems_version: 3.0.6
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: A voting gem
43
+ test_files: []