voteable_mtb 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 +15 -0
  2. data/lib/voteable_mtb.rb +21 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Zjk3NzQ1N2U2MzAxOWViYzYzNDUyYTg5NzU4YzhiYmNmMjFmODVhYQ==
5
+ data.tar.gz: !binary |-
6
+ ODYzMTBmZTg2MzcxNjU0OTk5NDcwYTYzN2IzZmMwMWVkOWMwYmFhZg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTVlN2FjNTVhZmMwYTc1MDczM2MxMjdkNjkyN2NjYjU2NmJjMTgyMmM0ZTBj
10
+ ZTFhZDc0ZGQ5YmZkNjU1M2E5ZmI4NzA0YzViMGQ0MzY3YzI4YmVlMGQxN2Ex
11
+ MTMzYzJlMmEyZjQwNDk3ZGVlMmQ3ZmNlOWIwMjIxYjkzODYzMzY=
12
+ data.tar.gz: !binary |-
13
+ OTMxMTNiOTIxYjVhYmNlNTZmMTExM2U2ZDVjYTdiNGM2OTZkYWVlNjc5ODI0
14
+ OGM2ZWJhODdmNWIyNWI4MzdmNjFiYzgzNDZmZWU5MmM5YzI3ZjdiZTIwZDEw
15
+ MWFhZThmNmI2OTAwZTZlOTYzOTRjZGRmZDE2ZGYwNmU2YWVmMzE=
@@ -0,0 +1,21 @@
1
+ # Using Concerns
2
+
3
+ module Voteable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_many :votes, as: :voteable
8
+ end
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
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_mtb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Lee
8
+ - MTB
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-07-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A generic voting gem
15
+ email: matbanbury@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/voteable_mtb.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.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A voting gem
44
+ test_files: []