voteable_danielt_test 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_danielt_test.rb +48 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 855ea75df97c506db4c63cd64e12aa9c3879f351
4
+ data.tar.gz: ca13f6539bbd26ec2a19d57fc4701b21cd3be7f4
5
+ SHA512:
6
+ metadata.gz: cb0a17132102e942b2d9d7d3b6a75719f1f52a8f3c10a1b402b38fd4a686c0e3e413ecf625fcd094da9b315530b0bd6dab909648a2c0f76b1f0f79fa9da51271
7
+ data.tar.gz: 6cc46e4882342a75cf685a3d00aff3bddc03351068f5ad2ec6ac33bbab585a99dbe0e3c70d223e2ebdef6c1bd7a4bd47e723f3ad19bcaaef94c21af700b394ec
@@ -0,0 +1,48 @@
1
+ module VoteableDanieltTest
2
+
3
+ # Mixin the ActiveSupport::Concern with Instance/Class method
4
+ extend ActiveSupport::Concern
5
+
6
+ # callback after included
7
+ included do
8
+
9
+ puts "-------------------------->"
10
+ puts "Debug: #{self.ancestors.second} has exbeen included."
11
+ puts "-------------------------->"
12
+ #--->
13
+ #polymorphic
14
+ has_many :votes, as: :voteable
15
+ #--->
16
+ end
17
+
18
+ #def method_name # mixin Instance method
19
+ #end
20
+
21
+ def total_votes
22
+ #self.votes.size
23
+ up_votes - down_votes
24
+ end
25
+
26
+ def up_votes
27
+ self.votes.where(vote: true).size
28
+ end
29
+
30
+ def down_votes
31
+ self.votes.where(vote: false).size
32
+ end
33
+
34
+
35
+ #module ClassMethods #mixin Class method
36
+ # def my_class_method
37
+ # end
38
+ #end
39
+
40
+ #ex: $ Post.my_class_method
41
+ #ex: $ post.class.my_class_method
42
+
43
+ module ClassMethods
44
+ def my_class_method
45
+ puts "This is a Class method. "
46
+ end
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_danielt_test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tealeaf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple gem which is uset to caculate vote.
14
+ email: tealeaf@tealeaf.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable_danielt_test.rb
20
+ homepage: http://github.com
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.5
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: voteable_danielt_test^_^
44
+ test_files: []