steamcannon-deltacloud-client 0.1.0.4 → 0.1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/base_object.rb +12 -17
- data/lib/deltacloud.rb +2 -2
- metadata +3 -3
data/lib/base_object.rb
CHANGED
@@ -192,7 +192,7 @@ module DeltaCloud
|
|
192
192
|
|
193
193
|
end
|
194
194
|
|
195
|
-
class
|
195
|
+
class StatefulObject < ActionObject
|
196
196
|
attr_reader :state
|
197
197
|
|
198
198
|
def initialize(opts={}, &block)
|
@@ -263,33 +263,28 @@ module DeltaCloud
|
|
263
263
|
end
|
264
264
|
|
265
265
|
def self.add_class(name, parent=:base)
|
266
|
-
|
267
|
-
|
268
|
-
when :action then 'ActionObject'
|
269
|
-
when :state then 'StateFullObject'
|
270
|
-
end
|
266
|
+
parent = parent.to_s
|
267
|
+
parent_class = "#{parent.classify}Object"
|
271
268
|
@defined_classes ||= []
|
272
|
-
|
273
|
-
class_name = "#{type_name}::#{name.classify}"
|
274
|
-
unless @defined_classes.include?(type_name)
|
275
|
-
DeltaCloud::API.class_eval("class #{parent.to_s.classify}; end")
|
276
|
-
@defined_classes << type_name
|
277
|
-
end
|
278
|
-
|
279
|
-
type_const = DeltaCloud::API.const_get(parent.to_s.classify)
|
269
|
+
class_name = "#{parent.classify}::#{name.classify}"
|
280
270
|
unless @defined_classes.include?(class_name)
|
281
|
-
|
271
|
+
DeltaCloud::API.class_eval("class #{class_name} < DeltaCloud::#{parent_class}; end")
|
282
272
|
@defined_classes << class_name
|
283
273
|
end
|
284
274
|
|
285
|
-
|
275
|
+
DeltaCloud::API.const_get(parent.classify).const_get(name.classify)
|
286
276
|
end
|
287
277
|
|
288
278
|
def self.guess_model_type(response)
|
289
279
|
response = Nokogiri::XML(response.to_s)
|
290
280
|
return :action if ((response/'//actions').length == 1) and ((response/'//state').length == 0)
|
291
|
-
return :
|
281
|
+
return :stateful if ((response/'//actions').length == 1) and ((response/'//state').length == 1)
|
292
282
|
return :base
|
293
283
|
end
|
294
284
|
|
285
|
+
class API
|
286
|
+
class Action; end
|
287
|
+
class Base; end
|
288
|
+
class Stateful; end
|
289
|
+
end
|
295
290
|
end
|
data/lib/deltacloud.rb
CHANGED
@@ -159,7 +159,7 @@ module DeltaCloud
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
-
# If there are actions, add
|
162
|
+
# If there are actions, add them to ActionObject/StatefulObject
|
163
163
|
if attribute.name == 'actions'
|
164
164
|
(attribute/'link').each do |link|
|
165
165
|
obj.add_action_link!(item['id'], link)
|
@@ -287,7 +287,7 @@ module DeltaCloud
|
|
287
287
|
|
288
288
|
# Re-raise backend errors as on exception in client with message from
|
289
289
|
# backend
|
290
|
-
class BackendError <
|
290
|
+
class BackendError < StandardError
|
291
291
|
def initialize(opts={})
|
292
292
|
@message = opts[:message]
|
293
293
|
end
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.1.0.
|
9
|
+
- 5
|
10
|
+
version: 0.1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat, Inc.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-08 00:00:00 -05:00
|
19
19
|
default_executable: deltacloudc
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|