api-scheme 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api/scheme.rb +9 -5
- data/lib/api/scheme/version.rb +1 -1
- 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: 75a892170b4408270c89604d758f48a04c8a36b7
|
4
|
+
data.tar.gz: f0505c014e326ca4baefbd76804440126e65d14d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 509ba012912da437e97351ffa09415f0262af4f5b7a201e8809e57d28e758936144a66cd010fbbd79c47cadf6db1064e50e942a23a5618e35b619b3bf76175e5
|
7
|
+
data.tar.gz: f82f6b8288f77d15d5b72c8ba73fade2faed53009f67d3da810f61157437dd2d4822a01c4651fa7cc7bb50d3990d7186ba6219efe950ded53f6f21a86d0e96dc
|
data/lib/api/scheme.rb
CHANGED
@@ -5,7 +5,7 @@ module Api::Scheme
|
|
5
5
|
def self.included klass
|
6
6
|
# NOTE put default render handlers to the module to use from as if is the ancestor
|
7
7
|
self.instance_variable_set(:@success_proc, :default_success_proc)
|
8
|
-
self.instance_variable_set(:@
|
8
|
+
self.instance_variable_set(:@error_proces, { nil => :default_error_proc })
|
9
9
|
|
10
10
|
klass.class_eval %Q"
|
11
11
|
class << self
|
@@ -26,11 +26,11 @@ module Api::Scheme
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def render_error_with method = nil, &prc
|
29
|
-
|
29
|
+
render_error_code nil => (method || prc)
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_error_code options = {}
|
33
|
-
@error_proces = (
|
33
|
+
@error_proces = _getter(:@error_proces).merge(options)
|
34
34
|
end
|
35
35
|
|
36
36
|
def use_model name
|
@@ -51,6 +51,10 @@ module Api::Scheme
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
def _getter var
|
56
|
+
self.ancestors.reduce(nil) { |value, klass| value || klass.instance_variable_get(var) }
|
57
|
+
end
|
54
58
|
end
|
55
59
|
"
|
56
60
|
|
@@ -58,7 +62,7 @@ module Api::Scheme
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def _getter var
|
61
|
-
self.class.
|
65
|
+
self.class._getter(var)
|
62
66
|
end
|
63
67
|
|
64
68
|
def error_map
|
@@ -165,7 +169,7 @@ module Api::Scheme
|
|
165
169
|
end
|
166
170
|
|
167
171
|
error_proces = _getter(:@error_proces)
|
168
|
-
error_proc = error_proces[code] ||
|
172
|
+
error_proc = error_proces[code] || error_proces[nil]
|
169
173
|
|
170
174
|
prc = error_proc.kind_of?(Proc) && error_proc || self.method(error_proc.to_s.to_sym)
|
171
175
|
args = [get_code_text(code), get_sub_code(code), get_pure_code(code), code, e ]
|
data/lib/api/scheme/version.rb
CHANGED