sinatra-has_scope 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sinatra/has_scope.rb +16 -14
- data/lib/sinatra/has_scope/version.rb +1 -1
- metadata +3 -3
data/lib/sinatra/has_scope.rb
CHANGED
@@ -78,20 +78,22 @@ module Sinatra
|
|
78
78
|
def apply_scopes(scope_group, target, hash)
|
79
79
|
return target unless scopes_configuration
|
80
80
|
|
81
|
-
self.scopes_configuration
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
81
|
+
if self.scopes_configuration.key?(scope_group)
|
82
|
+
self.scopes_configuration[scope_group].each do |scope, options|
|
83
|
+
key = options[:as].to_s
|
84
|
+
|
85
|
+
if hash.key?(key)
|
86
|
+
value, call_scope = hash[key], true
|
87
|
+
elsif options.key?(:default)
|
88
|
+
value, call_scope = options[:default], true
|
89
|
+
value = value.call(self) if value.is_a?(Proc)
|
90
|
+
end
|
91
|
+
|
92
|
+
value = parse_value(options[:type], key, value)
|
93
|
+
|
94
|
+
if call_scope && (value.present? || options[:allow_blank])
|
95
|
+
target = call_scope_by_type(options[:type], scope, target, value, options)
|
96
|
+
end
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-has_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Simon COURTOIS
|