voteable_mashrur 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_mashrur.rb +20 -0
  3. metadata +43 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62e99c794709f48d13fb06d8f5c3d110e3e05eeb
4
+ data.tar.gz: 4ac5fdac7523b8d972b1bd29b7305d3a490d226d
5
+ SHA512:
6
+ metadata.gz: 3c0d2b509dec2c59a727055a26539cee49bfe4a8e1b9947340bad939952e1c69783b255ec72cd0d6f136875d38f9c3d39a2ec69fdb5afe188bcebc96c270078d
7
+ data.tar.gz: d57750220f7d333661ae10e3ab0caf87bfbd0f13f270fb20d05070c3009233f11fac5a2639f18f645ae3dcb1b75737b9e4ccce5d4820f768d7ab07ada74e73b9
@@ -0,0 +1,20 @@
1
+ # Using Rails Concerns
2
+ module Voteable
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :votes, as: :voteable
7
+ end
8
+
9
+ def total_votes
10
+ self.up_votes - self.down_votes
11
+ end
12
+
13
+ def up_votes
14
+ self.votes.where(vote: true).size
15
+ end
16
+
17
+ def down_votes
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_mashrur
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mashrur Hossain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A very simple concise voting gem
14
+ email: mashrur.hossain@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable_mashrur.rb
20
+ homepage: http://github.com
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: A voting gem
43
+ test_files: []