cfoundry 0.3.4 → 0.3.5
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/cfoundry/v1/base.rb +1 -1
- data/lib/cfoundry/v2/client.rb +12 -6
- data/lib/cfoundry/v2/model.rb +11 -3
- data/lib/cfoundry/version.rb +1 -1
- metadata +4 -4
data/lib/cfoundry/v1/base.rb
CHANGED
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -154,13 +154,16 @@ module CFoundry::V2
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
define_method(:"#{singular}_from") do |path|
|
157
|
+
define_method(:"#{singular}_from") do |path, *args|
|
158
|
+
depth, _ = args
|
159
|
+
depth ||= 1
|
160
|
+
|
158
161
|
uri = URI.parse(path)
|
159
162
|
|
160
163
|
if uri.query
|
161
|
-
uri.query += "&inline-relations-depth
|
164
|
+
uri.query += "&inline-relations-depth=#{depth}"
|
162
165
|
else
|
163
|
-
uri.query = "inline-relations-depth
|
166
|
+
uri.query = "inline-relations-depth=#{depth}"
|
164
167
|
end
|
165
168
|
|
166
169
|
send(
|
@@ -171,13 +174,16 @@ module CFoundry::V2
|
|
171
174
|
nil => :json))
|
172
175
|
end
|
173
176
|
|
174
|
-
define_method(:"#{plural}_from") do |path|
|
177
|
+
define_method(:"#{plural}_from") do |path, *args|
|
178
|
+
depth, _ = args
|
179
|
+
depth ||= 1
|
180
|
+
|
175
181
|
uri = URI.parse(path)
|
176
182
|
|
177
183
|
if uri.query
|
178
|
-
uri.query += "&inline-relations-depth
|
184
|
+
uri.query += "&inline-relations-depth=#{depth}"
|
179
185
|
else
|
180
|
-
uri.query = "inline-relations-depth
|
186
|
+
uri.query = "inline-relations-depth=#{depth}"
|
181
187
|
end
|
182
188
|
|
183
189
|
@base.request_path(
|
data/lib/cfoundry/v2/model.rb
CHANGED
@@ -28,7 +28,10 @@ module CFoundry::V2
|
|
28
28
|
if manifest[:entity].key? name
|
29
29
|
@client.send(:"make_#{obj}", manifest[:entity][name])
|
30
30
|
else
|
31
|
-
@client.send(
|
31
|
+
@client.send(
|
32
|
+
:"#{obj}_from",
|
33
|
+
send("#{name}_url"),
|
34
|
+
opts[:depth] || 1)
|
32
35
|
end
|
33
36
|
}
|
34
37
|
|
@@ -46,7 +49,9 @@ module CFoundry::V2
|
|
46
49
|
|
47
50
|
def to_many(plural, opts = {})
|
48
51
|
singular = plural.to_s.sub(/s$/, "").to_sym
|
52
|
+
|
49
53
|
object = opts[:as] || singular
|
54
|
+
plural_object = object.to_s.sub(/s$/, "").to_sym
|
50
55
|
|
51
56
|
define_method(plural) {
|
52
57
|
if manifest[:entity].key? plural
|
@@ -54,7 +59,10 @@ module CFoundry::V2
|
|
54
59
|
@client.send(:"make_#{object}", json)
|
55
60
|
end
|
56
61
|
else
|
57
|
-
@client.send(
|
62
|
+
@client.send(
|
63
|
+
:"#{plural_object}_from",
|
64
|
+
send("#{plural}_url"),
|
65
|
+
opts[:depth] || 1)
|
58
66
|
end
|
59
67
|
}
|
60
68
|
|
@@ -115,7 +123,7 @@ module CFoundry::V2
|
|
115
123
|
@manifest =
|
116
124
|
@client.base.send(
|
117
125
|
:"create_#{object_name}",
|
118
|
-
@manifest[:entity]
|
126
|
+
self.class.defaults.merge(@manifest[:entity]))
|
119
127
|
|
120
128
|
@id = @manifest[:metadata][:guid]
|
121
129
|
|
data/lib/cfoundry/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|