voteable_hw 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_hw.rb +22 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 76b91bacda2df40959e8ff130477c88c57fe5863
4
+ data.tar.gz: add5b8ce37e710362c83c23c039fd7075a8792b0
5
+ SHA512:
6
+ metadata.gz: 04afafd79225c025f347ede5cd49f9d34984f28f5d3e59c18320e554848a56a90f1eecee5834c54d30aa31e2f490bfce37e1f38e6e2584baecc2d400b521e68f
7
+ data.tar.gz: 18510bee5d2b43c508eb5d6aec5e3a87dc0f6a1550e96ec9d8e6d84d853eb962ee41eb0926c6694bf1ab4044028a53adb3fb3d126c4b8229205d9452bbb5d1b0
@@ -0,0 +1,22 @@
1
+ # Using Concerns
2
+
3
+ module Voteable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ #puts "This is class method!"
8
+ has_many :votes, as: :voteable
9
+ end
10
+
11
+ def total_votes
12
+ self.up_votes - self.down_votes
13
+ end
14
+
15
+ def up_votes
16
+ self.votes.where(vote: true).size
17
+ end
18
+
19
+ def down_votes
20
+ self.votes.where(vote: false).size
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_hw
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Huawei Weng
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The best voting gem.
14
+ email:
15
+ - wengny@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/voteable_hw.rb
21
+ homepage: http://github.com/
22
+ licenses:
23
+ - APACHE2
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A voting gem
45
+ test_files: []