voteable_abuckingham 0.1.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_abuckingham.rb +19 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d023bc7c21fc7fc1129170c9a0abba799aaff03d
4
+ data.tar.gz: a4706828fa366db0a0f319769fa8dd5071aedc85
5
+ SHA512:
6
+ metadata.gz: 5150b87ad0c338a75a2a2982a9cd98a5539a18eed0a721bae15c0aa8878469cdf37b1f9c92f801d1cadd8b3cee678b7b4feda83c96dd0f6797f502525de7a057
7
+ data.tar.gz: ec8af77da45dc112d05a8a26e539d2503091d250cdbdbf28c9a7e42aa922d99459f8582c75cb00c0e39abf482bfd45532165893f43c7747d86786b4e13e8a90e
@@ -0,0 +1,19 @@
1
+ module Voteable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_many :votes, as: :voteable
6
+
7
+ def total_votes
8
+ self.up_votes - self.down_votes
9
+ end
10
+
11
+ def up_votes
12
+ self.votes.where(vote: true).size
13
+ end
14
+
15
+ def down_votes
16
+ self.votes.where(vote: false).size
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_abuckingham
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Buckingham
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem that contains voteable module logic
14
+ email: andrew@andrewbuckingham.net
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable_abuckingham.rb
20
+ homepage: https://github.com/XiaoA/voteable-abuckingham-gem
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.6
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A voting gem
44
+ test_files: []