grape_has_scope 0.1.0 → 0.2.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 +4 -4
- data/lib/grape_has_scope.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76ee58631c46df1318d9663e481924f8c1784e83
|
|
4
|
+
data.tar.gz: dbafe90a84dbf979654dea35915466b8d2d28fa3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf7fd0af8528122425eda72356c7deaf0aa086215dbd20650b09025306bcb667616c780218137c3813f6a3ace2d70e31c46e8d1fb4f27a0d3c87d179ff850d62
|
|
7
|
+
data.tar.gz: 03f63c8ba58ea3f0eea4924caa120d6b09031902564fb7d5f08727304b89c861e8a2b340b0cc7fa099275cdbf344ac19840fcb63e2d25691989bc399b88ab4cf
|
data/lib/grape_has_scope.rb
CHANGED
|
@@ -10,7 +10,7 @@ module GrapeHasScope
|
|
|
10
10
|
|
|
11
11
|
def self.included(base)
|
|
12
12
|
base.class_eval do
|
|
13
|
-
|
|
13
|
+
attr_accessor :scopes_configuration
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -32,11 +32,11 @@ module GrapeHasScope
|
|
|
32
32
|
options[:only] = Array(options[:only])
|
|
33
33
|
options[:except] = Array(options[:except])
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
@scopes_configuration = (@scopes_configuration || {}).dup
|
|
36
36
|
|
|
37
37
|
scopes.each do |scope|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
@scopes_configuration[scope] ||= { :as => scope, :type => :default, :block => block }
|
|
39
|
+
@scopes_configuration[scope] = @scopes_configuration[scope].merge(options)
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ module GrapeHasScope
|
|
|
54
54
|
def apply_scopes(target, hash=params)
|
|
55
55
|
return target unless scopes_configuration
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
@scopes_configuration.each do |scope, options|
|
|
58
58
|
next unless apply_scope_to_action?(options)
|
|
59
59
|
key = options[:as]
|
|
60
60
|
|