cfoundry 0.3.41 → 0.3.42
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/v2/app.rb +2 -0
- data/lib/cfoundry/v2/client.rb +28 -5
- data/lib/cfoundry/v2/domain.rb +2 -0
- data/lib/cfoundry/v2/model.rb +10 -0
- data/lib/cfoundry/v2/route.rb +2 -0
- data/lib/cfoundry/v2/service_instance.rb +2 -0
- data/lib/cfoundry/v2/space.rb +2 -0
- data/lib/cfoundry/version.rb +1 -1
- metadata +4 -4
data/lib/cfoundry/v2/app.rb
CHANGED
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -150,21 +150,41 @@ module CFoundry::V2
|
|
150
150
|
|
151
151
|
klass = CFoundry::V2.const_get(classname)
|
152
152
|
|
153
|
-
|
153
|
+
scoped_organization = klass.scoped_organization
|
154
|
+
scoped_space = klass.scoped_space
|
155
|
+
|
154
156
|
has_name = klass.method_defined? :name
|
155
157
|
|
156
158
|
define_method(singular) do |*args|
|
157
159
|
guid, _ = args
|
158
|
-
|
160
|
+
|
161
|
+
x = klass.new(guid, self)
|
162
|
+
|
163
|
+
# when creating an object, automatically set the org/space
|
164
|
+
unless guid
|
165
|
+
if scoped_organization && current_organization
|
166
|
+
x.send(:"#{scoped_organization}=", current_organization)
|
167
|
+
end
|
168
|
+
|
169
|
+
if scoped_space && current_space
|
170
|
+
x.send(:"#{scoped_space}=", current_space)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
x
|
159
175
|
end
|
160
176
|
|
161
177
|
define_method(plural) do |*args|
|
162
178
|
depth, query = args
|
163
179
|
depth ||= 1
|
164
180
|
|
165
|
-
|
181
|
+
# use current org/space
|
182
|
+
if scoped_space && current_space
|
183
|
+
query ||= {}
|
184
|
+
query[:"#{scoped_space}_guid"] ||= current_space.guid
|
185
|
+
elsif scoped_organization && current_organization
|
166
186
|
query ||= {}
|
167
|
-
query[:
|
187
|
+
query[:"#{scoped_organization}_guid"] ||= current_organization.guid
|
168
188
|
end
|
169
189
|
|
170
190
|
@base.send(plural, depth, query).collect do |json|
|
@@ -177,8 +197,11 @@ module CFoundry::V2
|
|
177
197
|
depth, _ = args
|
178
198
|
depth ||= 1
|
179
199
|
|
180
|
-
|
200
|
+
# use current org/space
|
201
|
+
if scoped_space && current_space
|
181
202
|
current_space.send(plural, depth, :name => name).first
|
203
|
+
elsif scoped_organization && current_organization
|
204
|
+
current_organization.send(plural, depth, :name => name).first
|
182
205
|
else
|
183
206
|
send(plural, depth, :name => name).first
|
184
207
|
end
|
data/lib/cfoundry/v2/domain.rb
CHANGED
data/lib/cfoundry/v2/model.rb
CHANGED
@@ -3,6 +3,8 @@ require "multi_json"
|
|
3
3
|
module CFoundry::V2
|
4
4
|
class Model
|
5
5
|
class << self
|
6
|
+
attr_reader :scoped_organization, :scoped_space
|
7
|
+
|
6
8
|
def value_matches?(val, type)
|
7
9
|
case type
|
8
10
|
when Class
|
@@ -61,6 +63,14 @@ module CFoundry::V2
|
|
61
63
|
}
|
62
64
|
end
|
63
65
|
|
66
|
+
def scoped_to_organization(relation = :organization)
|
67
|
+
@scoped_organization = relation
|
68
|
+
end
|
69
|
+
|
70
|
+
def scoped_to_space(relation = :space)
|
71
|
+
@scoped_space = relation
|
72
|
+
end
|
73
|
+
|
64
74
|
def to_one(name, opts = {})
|
65
75
|
obj = opts[:as] || name
|
66
76
|
kls = obj.to_s.capitalize.gsub(/(.)_(.)/) do
|
data/lib/cfoundry/v2/route.rb
CHANGED
data/lib/cfoundry/v2/space.rb
CHANGED
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: 71
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 42
|
10
|
+
version: 0.3.42
|
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-10-
|
18
|
+
date: 2012-10-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|