voteable_aaron_mar 0.0.1

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_aaron_mar.rb +31 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7704b8352219f9e6bc6d5104131b666941dccd00
4
+ data.tar.gz: daa82481b5c7d9cbd55a255d78b5aa7080b12d87
5
+ SHA512:
6
+ metadata.gz: 20f2c36c3a545f3da2763b6ebb92ecdfa78ea221347a8828c8d6b9b9f91b72f40534c6244c748cf99c6545a439b1177f0d930afe8be906f4926ae56b517c0f40
7
+ data.tar.gz: e07383eb3fff850ff9cad5e4d1818670c5a1f4ed956851b985415cad825f7de02d50f2ee7ced6958f9b4873b16b82f21bc763b2c557abb6a9336b9b7c1b2507d
@@ -0,0 +1,31 @@
1
+ module VoteableAaronMar
2
+
3
+ def self.included(base)
4
+ base.send(:include, InstanceMethods)
5
+ base.extend ClassMethods
6
+ base.class_eval do #run class method when class created
7
+ model_voteable
8
+ end
9
+ end
10
+
11
+ module InstanceMethods
12
+ def total_votes
13
+ up_votes - down_votes
14
+ end
15
+
16
+ def up_votes
17
+ self.votes.where(vote: true).size
18
+ end
19
+
20
+ def down_votes
21
+ self.votes.where(vote: false).size
22
+ end
23
+ end
24
+
25
+ module ClassMethods
26
+ def model_voteable
27
+ has_many :votes, as: :voteable
28
+ end
29
+ end
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_aaron_mar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Chang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Extract voteable behavior into a gem, it counts total votes for a comment/post
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable_aaron_mar.rb
20
+ homepage: https://rubygems.org
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.4.2
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: A voteable gem
43
+ test_files: []
44
+ has_rdoc: