voteable_koen 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.
- checksums.yaml +7 -0
- data/lib/voteable.rb +27 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8423bc9a9e5b64d2a05d5c76f2432b126305d98d
|
4
|
+
data.tar.gz: b4ba33c7e43833a630dfdc435e583cc3237cc8c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2bf572124b7c3d975ec1e075ed1356a45c7641839bb67e84643201f140007d07c3de351d90ff30625ec1316a618ac756b8bfb315bdf050c412020179fe616021
|
7
|
+
data.tar.gz: dca206a3a342b67a66341630f145ab3ec1f1dc4e4fa0347b3ae45f67ead305069962ef464efcbddc09d27df252e397af7a1b4562dc64fc412bd9cfa61e1f656c
|
data/lib/voteable.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Voteable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_many :votes, as: :voteable
|
6
|
+
end
|
7
|
+
|
8
|
+
def votes_total
|
9
|
+
@votes_total ||= votes_up - votes_down
|
10
|
+
end
|
11
|
+
|
12
|
+
def votes_up
|
13
|
+
votes.where(vote: true).size
|
14
|
+
end
|
15
|
+
|
16
|
+
def votes_down
|
17
|
+
votes.where(vote: false).size
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_voted_up?(user)
|
21
|
+
votes.where(vote: true, creator: user).exists?
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_voted_down?(user)
|
25
|
+
votes.where(vote: false, creator: user).exists?
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: voteable_koen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Koen Werdler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem contains the voteable module from the PostIt! application.
|
14
|
+
email: koen@werdler.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/voteable.rb
|
20
|
+
homepage: http://www.codefish.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.2.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Adds voteable functionality
|
43
|
+
test_files: []
|