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.
@@ -58,7 +58,7 @@ module CFoundry::V1
58
58
  end
59
59
 
60
60
  def create_user(payload)
61
- post(payload, "users")
61
+ post(payload, "users", :json => nil)
62
62
  end
63
63
 
64
64
  def user(email)
@@ -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=1"
164
+ uri.query += "&inline-relations-depth=#{depth}"
162
165
  else
163
- uri.query = "inline-relations-depth=1"
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=1"
184
+ uri.query += "&inline-relations-depth=#{depth}"
179
185
  else
180
- uri.query = "inline-relations-depth=1"
186
+ uri.query = "inline-relations-depth=#{depth}"
181
187
  end
182
188
 
183
189
  @base.request_path(
@@ -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(:"#{name}_from", send("#{obj}_url"))
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(:"#{plural}_from", send("#{plural}_url"))
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].merge(self.class.defaults))
126
+ self.class.defaults.merge(@manifest[:entity]))
119
127
 
120
128
  @id = @manifest[:metadata][:guid]
121
129
 
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.3.4"
3
+ VERSION = "0.3.5"
4
4
  end
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
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-15 00:00:00 Z
18
+ date: 2012-07-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client