dato 0.7.17 → 0.7.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dato/api_client.rb +42 -15
- data/lib/dato/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43d5a65257051385168de064d1b162bbd0bc5d0ef8523a2079d2f9051dc6b509
|
4
|
+
data.tar.gz: 23a9293ed05685fd635de711d3b98084dcb9efc92735d0e379b7640798e8a959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd30a74fe816ab8d4a3683d62ddfecd1ce350f94c94a4f4bbbcaaabaf88a94677f939c8d7cfaf0c9769040d03adc7da829229d5e8762610491ca7d199244e082
|
7
|
+
data.tar.gz: 47ebdc307a2c8ae71cd28f0b7ce60c4e2f14802951bbed9b90bd93ff359bd41c240dc3dc4c834febafd32ebe81b4f735f05f9d01a2f7ea245ad9df4324938501
|
data/lib/dato/api_client.rb
CHANGED
@@ -33,27 +33,54 @@ module Dato
|
|
33
33
|
@extra_headers = options[:extra_headers] || {}
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
define_singleton_method(:subdomain) do
|
37
|
+
subdomain
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def respond_to_missing?(method, include_private = false)
|
43
|
+
json_schema.definitions.each do |type, obj|
|
44
|
+
is_collection = obj.links.select { |x| x.rel == 'instances' }.any?
|
45
|
+
namespace = is_collection ? type.pluralize : type
|
46
|
+
if method.to_s === namespace
|
47
|
+
return true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def method_missing(method, *args, &block)
|
55
|
+
json_schema.definitions.each do |type, obj|
|
56
|
+
is_collection = obj.links.select { |x| x.rel == 'instances' }.any?
|
57
|
+
namespace = is_collection ? type.pluralize : type
|
58
|
+
|
59
|
+
if method.to_s === namespace
|
60
|
+
instance_variable_set(
|
61
|
+
"@#{namespace}",
|
62
|
+
instance_variable_get("@#{namespace}") ||
|
63
|
+
Dato::Repo.new(self, type, obj)
|
64
|
+
)
|
65
|
+
|
66
|
+
return instance_variable_get("@#{namespace}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
super
|
71
|
+
end
|
72
|
+
|
73
|
+
def json_schema
|
74
|
+
@json_schema ||= begin
|
38
75
|
response = Faraday.get(
|
39
|
-
"
|
76
|
+
# "http://#{subdomain}.lvh.me:3001/docs/#{subdomain}-hyperschema.json"
|
77
|
+
"#{base_url}/docs/#{self.class.subdomain}-hyperschema.json"
|
40
78
|
)
|
41
79
|
|
42
80
|
schema = JsonSchema.parse!(JSON.parse(response.body))
|
43
81
|
schema.expand_references!
|
44
82
|
|
45
|
-
schema
|
46
|
-
is_collection = obj.links.select { |x| x.rel == 'instances' }.any?
|
47
|
-
namespace = is_collection ? type.pluralize : type
|
48
|
-
|
49
|
-
define_method(namespace) do
|
50
|
-
instance_variable_set(
|
51
|
-
"@#{namespace}",
|
52
|
-
instance_variable_get("@#{namespace}") ||
|
53
|
-
Dato::Repo.new(self, type, obj)
|
54
|
-
)
|
55
|
-
end
|
56
|
-
end
|
83
|
+
schema
|
57
84
|
end
|
58
85
|
end
|
59
86
|
|
data/lib/dato/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|