interpol 0.7.2 → 0.7.3
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.
- data/lib/interpol/dynamic_struct.rb +28 -16
- data/lib/interpol/version.rb +1 -1
- metadata +2 -3
- data/lib/interpol/hash_set_default_proc_18.rb +0 -9
@@ -10,35 +10,47 @@ module Interpol
|
|
10
10
|
# everything. This is handy so that consumers of this gem can distinguish
|
11
11
|
# between a fat-fingered field, and a field that is set to nil.
|
12
12
|
module DynamicStruct
|
13
|
-
|
14
|
-
raise NoMethodError, "undefined method `#{key}' for #{hash.inspect}"
|
15
|
-
end
|
13
|
+
SAFE_METHOD_MISSING = ::Hashie::Mash.superclass.instance_method(:method_missing)
|
16
14
|
|
17
15
|
Mash = Class.new(::Hashie::Mash) do
|
18
16
|
undef sort
|
19
17
|
end
|
20
18
|
|
21
|
-
def self.new(
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
def self.new(*args)
|
20
|
+
Mash.new(*args).tap do |mash|
|
21
|
+
mash.extend(self)
|
22
|
+
end
|
25
23
|
end
|
26
24
|
|
27
|
-
def self.
|
25
|
+
def self.extended(mash)
|
26
|
+
recursively_extend(mash)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.recursively_extend(object)
|
28
30
|
case object
|
29
31
|
when Array
|
30
|
-
object.each { |
|
31
|
-
when
|
32
|
-
|
33
|
-
|
32
|
+
object.each { |v| recursively_extend(v) }
|
33
|
+
when Mash
|
34
|
+
object.extend(self) unless object.is_a?(self)
|
35
|
+
object.each { |_, v| recursively_extend(v) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def method_missing(method_name, *args, &blk)
|
40
|
+
if key = method_name.to_s[/\A([^?=]*)[?=]?\z/, 1]
|
41
|
+
unless has_key?(key)
|
42
|
+
return safe_method_missing(method_name, *args, &blk)
|
43
|
+
end
|
34
44
|
end
|
45
|
+
|
46
|
+
super
|
35
47
|
end
|
36
48
|
|
37
|
-
|
38
|
-
|
49
|
+
private
|
50
|
+
|
51
|
+
def safe_method_missing(*args)
|
52
|
+
SAFE_METHOD_MISSING.bind(self).call(*args)
|
39
53
|
end
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
43
|
-
require 'interpol/hash_set_default_proc_18' unless {}.respond_to?(:default_proc=)
|
44
|
-
|
data/lib/interpol/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interpol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -194,7 +194,6 @@ files:
|
|
194
194
|
- lib/interpol/each_with_object.rb
|
195
195
|
- lib/interpol/endpoint.rb
|
196
196
|
- lib/interpol/errors.rb
|
197
|
-
- lib/interpol/hash_set_default_proc_18.rb
|
198
197
|
- lib/interpol/request_body_validator.rb
|
199
198
|
- lib/interpol/request_params_parser.rb
|
200
199
|
- lib/interpol/response_schema_validator.rb
|