voteable_kelvin 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.
- checksums.yaml +7 -0
- data/lib/voteable_kelvin.rb +20 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a1ece122fdce9c5ec68eaaa2497a422bd23545d
|
4
|
+
data.tar.gz: df71ac2f476e1b1caefc8aee018fe43df531454e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ad5855b5756a173f01040b417cf9ef0843e836dbb0a46e06e39ced7dc955fa5292c3be295bccd842e55f89e46348ab6c611feb56dd253fab3122598d543e350
|
7
|
+
data.tar.gz: a115d98125a74ce35113a5ce7f43be7e447a5b912eefc0b92e4b088c755dd8589df8f189bc2d5c355d551ba3d56fdb14ae51ebcca0850fb840cbb1aaa993b7b5
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Voteable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_many :votes, as: :voteable
|
6
|
+
end
|
7
|
+
|
8
|
+
def counter(params)
|
9
|
+
params == 'true' ? self.increment!(:vote_count) : self.decrement!(:vote_count)
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_vote(user)
|
13
|
+
@current_vote ||= self.votes.find_by(creator: user)
|
14
|
+
end
|
15
|
+
|
16
|
+
def change_vote(params)
|
17
|
+
self.counter(params) if @current_vote.vote.to_s != params
|
18
|
+
@current_vote.update(vote: params)
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: voteable_kelvin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kelvin Rodriguez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Keep track of any model with votes. Create a vote_count column, and include
|
14
|
+
Voteable.
|
15
|
+
email: me@kelvinrodriguez.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/voteable_kelvin.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: []
|