voteable_ellery_mar 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.rb +20 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 56c9c5e166cadcde53aa4a279a3a923f98b81f7d
4
+ data.tar.gz: 1a3b35343c21919eb8a7bf8fdf4e0fa32d228231
5
+ SHA512:
6
+ metadata.gz: 4c57e9e073628c810c65bd91328904bbaedc5bc9cb1ae8152f6421de3232e0e702e6fedb9a3f230aa62b9eb1e062045eebbf234fa644250f9818b80fa6d4a5ef
7
+ data.tar.gz: c10affc0b749efc19cd4c76b6c14dd8864bcec15a40d5f09aa83bad9561417405dc481622b9668034873e0364372b6b9f3dbfa833aef71640226e7a805e46d21
data/lib/voteable.rb ADDED
@@ -0,0 +1,20 @@
1
+ module Voteable
2
+ extend ActiveSupport::Concern #makes methods below instance methods
3
+
4
+ included do
5
+ has_many :votes, as: :voteable
6
+ end
7
+
8
+ def total_votes
9
+ up_votes - down_votes
10
+ end
11
+
12
+ def up_votes
13
+ self.votes.where(vote: true).count
14
+ end
15
+
16
+ def down_votes
17
+ self.votes.where(vote: false).count
18
+ end
19
+
20
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voteable_ellery_mar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ellery Temple Jr.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Gotealeaf create gem lesson
14
+ email: elreyatee@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/voteable.rb
20
+ homepage: http://rubygems.org/gems/voteable
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.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: This is a sample voteable gem
44
+ test_files: []