ratable 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/ratable.js.erb +1 -2
- data/app/assets/stylesheets/ratable.scss +16 -0
- data/lib/ratable/models/ratee.rb +15 -40
- data/lib/ratable/models/ratee_rater.rb +0 -1
- data/lib/ratable/models/rater.rb +1 -1
- data/lib/ratable/version.rb +1 -1
- data/spec/dummy/app/models/user.rb +2 -1
- metadata +3 -3
- data/app/assets/javascripts/ratings.js +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b73a6b2a07a0e7148f91bdfa503d6d849e0621e
|
4
|
+
data.tar.gz: 1f5ee31f7d742e84326135d5c4042be6cfe0fc5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e0271f3f1855f1fb22a53e546f97554c9ca98367d25390b478fa11119c96887d629cb5befc955ba39a3261ba8a8b8bf4b2ee1fc62f494432568819f2bfff62
|
7
|
+
data.tar.gz: 5e4383b223bf6cf7ae9a988abb0d7226b9f96ddf0a8de514a3a0f00d5b5bf76a4e1f170b001ab3ff78e8fa9a72a464a8f205fc0300e4e0665a1bb1a775dd33e8
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into ratable.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require jquery.raty.css
|
14
|
+
*= require_tree .
|
15
|
+
*= require_self
|
16
|
+
*/
|
data/lib/ratable/models/ratee.rb
CHANGED
@@ -2,66 +2,41 @@ module Ratable
|
|
2
2
|
module Models
|
3
3
|
module Ratee
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
extend Ratable::ActiveRecordExtension
|
6
5
|
|
7
6
|
attr_reader :has_one
|
8
7
|
|
9
8
|
module ActiveRecordExtension
|
10
9
|
def acts_as_ratee(options={has_one: false})
|
11
|
-
|
10
|
+
raise "To make a model the rater and the ratee use `acts_as_ratee_and_rater`" if acts_like_rater?
|
12
11
|
@has_one = options[:has_one]
|
13
12
|
include Ratee
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
16
|
included do
|
18
|
-
|
19
|
-
|
20
|
-
has_one :rating, class_name: 'Ratable::Rating', dependent: :destroy, as: :ratee
|
21
|
-
else
|
22
|
-
has_many :ratings, class_name: 'Ratable::Rating', dependent: :destroy, as: :ratee
|
23
|
-
end
|
17
|
+
if @has_one
|
18
|
+
has_one :rating, class_name: 'Ratable::Rating', dependent: :destroy, as: :ratee
|
24
19
|
else
|
25
|
-
|
26
|
-
has_one :ratee_rating, class_name: 'Ratable::Rating', dependent: :destroy, as: :ratee
|
27
|
-
else
|
28
|
-
has_many :ratee_ratings, class_name: 'Ratable::Rating', dependent: :destroy, as: :ratee
|
29
|
-
end
|
20
|
+
has_many :ratings, class_name: 'Ratable::Rating', dependent: :destroy, as: :ratee
|
30
21
|
end
|
31
22
|
end
|
32
23
|
|
33
24
|
def raters
|
34
|
-
|
35
|
-
|
36
|
-
rating.rater
|
37
|
-
else
|
38
|
-
ratings.includes(:rater).collect { |rating| rating.rater }
|
39
|
-
end
|
25
|
+
if @has_one
|
26
|
+
rating.rater
|
40
27
|
else
|
41
|
-
|
42
|
-
ratee_rating.rater
|
43
|
-
else
|
44
|
-
ratee_ratings.includes(:rater).collect { |rating| rating.rater }
|
45
|
-
end
|
28
|
+
ratings.includes(:rater).collect { |rating| rating.rater }
|
46
29
|
end
|
47
30
|
end
|
48
31
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# else
|
58
|
-
# if @has_one
|
59
|
-
# self.ratee_rating.create(options)
|
60
|
-
# else
|
61
|
-
# self.ratee_ratings.create(options)
|
62
|
-
# end
|
63
|
-
# end
|
64
|
-
# end
|
32
|
+
def rate(options={})
|
33
|
+
options.reject! { |k| k == :ratee }
|
34
|
+
if @has_one
|
35
|
+
self.rating.create(options)
|
36
|
+
else
|
37
|
+
self.ratings.create(options)
|
38
|
+
end
|
39
|
+
end
|
65
40
|
|
66
41
|
end
|
67
42
|
end
|
data/lib/ratable/models/rater.rb
CHANGED
@@ -7,7 +7,7 @@ module Ratable
|
|
7
7
|
|
8
8
|
module ActiveRecordExtension
|
9
9
|
def acts_as_rater(options={has_one: false})
|
10
|
-
|
10
|
+
raise "To make a model the rater and the ratee use `acts_as_ratee_and_rater`" if acts_like_ratee?
|
11
11
|
@has_one = options[:has_one]
|
12
12
|
include Rater
|
13
13
|
end
|
data/lib/ratable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François Bélanger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -120,7 +120,7 @@ files:
|
|
120
120
|
- README.rdoc
|
121
121
|
- Rakefile
|
122
122
|
- app/assets/javascripts/ratable.js.erb
|
123
|
-
- app/assets/
|
123
|
+
- app/assets/stylesheets/ratable.scss
|
124
124
|
- app/models/ratable/rating.rb
|
125
125
|
- app/views/ratable/ratings/_rating.html.erb
|
126
126
|
- db/migrate/20160418175804_create_ratable_ratings.rb
|