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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0fd61e5d4325b608b2ff6566e9a35b96ed319d5
4
- data.tar.gz: 52bb05fc01b485a4d640985497cbbec006199a7e
3
+ metadata.gz: 75a892170b4408270c89604d758f48a04c8a36b7
4
+ data.tar.gz: f0505c014e326ca4baefbd76804440126e65d14d
5
5
  SHA512:
6
- metadata.gz: 0304ba3e05d26ee02d8bc2840f21ebdac93bb6b7a6d6571b3cff59921249dcc364d710862217d64387598614491d781de55b12c03467109f1a381640b6c4df84
7
- data.tar.gz: fb84a3d697a31a0f5a37760cafdf8cf78f25101ef0f3a1672b47628b373e7af80861049ca67b153f92d07664c9ed8651756517fa4fa8c7de0cf58c8a254b8388
6
+ metadata.gz: 509ba012912da437e97351ffa09415f0262af4f5b7a201e8809e57d28e758936144a66cd010fbbd79c47cadf6db1064e50e942a23a5618e35b619b3bf76175e5
7
+ data.tar.gz: f82f6b8288f77d15d5b72c8ba73fade2faed53009f67d3da810f61157437dd2d4822a01c4651fa7cc7bb50d3990d7186ba6219efe950ded53f6f21a86d0e96dc
@@ -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(:@error_proc, :default_error_proc)
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
- @error_proc ||= method || prc
29
+ render_error_code nil => (method || prc)
30
30
  end
31
31
 
32
32
  def render_error_code options = {}
33
- @error_proces = (@error_proces || {}).merge(options)
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.ancestors.reduce(nil) { |value, klass| value || klass.instance_variable_get(var) }
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] || error_proc = _getter(:@error_proc)
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 ]
@@ -1,5 +1,5 @@
1
1
  module Api
2
2
  module Scheme
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-scheme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Malo Skrylevo