occi-core 5.0.0.beta.8 → 5.0.0.beta.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/occi/core/entity.rb +27 -5
- data/lib/occi/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf964beebc12970fdcaf0ab624593f4bb73b74f
|
4
|
+
data.tar.gz: 2d8c4b87e3c5948beef5be425e5042478f4734c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad87812e470b99636a412f54b09e881d30acbaa01cb371f52f72821cf1166a76cbcf125ab610e292b9443d3dfeb14053acd0232d709889ec16ed03c9e5382a4
|
7
|
+
data.tar.gz: b8be9a5d023b5a944a756f19ae8ff5756671d46c48f910377729d8ba5a51bdd6f1bd7741540203db868c9cf15e3e9d4538a6c466c457d1cb23b6facf86f50fc8
|
data/lib/occi/core/entity.rb
CHANGED
@@ -222,9 +222,8 @@ module Occi
|
|
222
222
|
#
|
223
223
|
# @param action [Occi::Core::Action] action to be added
|
224
224
|
def add_action(action)
|
225
|
-
unless action
|
226
|
-
raise Occi::Core::Errors::MandatoryArgumentError,
|
227
|
-
'Cannot add a non-existent action'
|
225
|
+
unless action && kind.actions.include?(action)
|
226
|
+
raise Occi::Core::Errors::MandatoryArgumentError, 'Cannot add an action that is empty or not defined on kind'
|
228
227
|
end
|
229
228
|
actions << action
|
230
229
|
end
|
@@ -234,12 +233,35 @@ module Occi
|
|
234
233
|
# @param action [Occi::Core::Action] action to be removed
|
235
234
|
def remove_action(action)
|
236
235
|
unless action
|
237
|
-
raise Occi::Core::Errors::MandatoryArgumentError,
|
238
|
-
'Cannot remove a non-existent action'
|
236
|
+
raise Occi::Core::Errors::MandatoryArgumentError, 'Cannot remove a non-existent action'
|
239
237
|
end
|
240
238
|
actions.delete action
|
241
239
|
end
|
242
240
|
|
241
|
+
# Enables action identified by `term` on this instance. Actions are looked up
|
242
|
+
# in `kind.actions`. Unknown actions will raise errors.
|
243
|
+
#
|
244
|
+
# @example
|
245
|
+
# entity.enable_action 'start'
|
246
|
+
#
|
247
|
+
# @param term [String] action term
|
248
|
+
def enable_action(term)
|
249
|
+
add_action(kind.actions.detect { |a| a.term == term })
|
250
|
+
end
|
251
|
+
|
252
|
+
# Disables action identified by `term` on this instance. Unknown actions
|
253
|
+
# will NOT raise errors.
|
254
|
+
#
|
255
|
+
# @example
|
256
|
+
# entity.disable_action 'start'
|
257
|
+
#
|
258
|
+
# @param term [String] action term
|
259
|
+
def disable_action(term)
|
260
|
+
action = actions.detect { |a| a.term == term }
|
261
|
+
return unless action
|
262
|
+
remove_action action
|
263
|
+
end
|
264
|
+
|
243
265
|
# Validates the content of this entity instance, including
|
244
266
|
# all previously defined OCCI attributes and other required
|
245
267
|
# elements. This method limits the information returned to
|
data/lib/occi/core/version.rb
CHANGED
@@ -3,7 +3,7 @@ module Occi
|
|
3
3
|
MAJOR_VERSION = 5 # Major update constant
|
4
4
|
MINOR_VERSION = 0 # Minor update constant
|
5
5
|
PATCH_VERSION = 0 # Patch/Fix version constant
|
6
|
-
STAGE_VERSION = 'beta.
|
6
|
+
STAGE_VERSION = 'beta.9'.freeze # use `nil` for production releases
|
7
7
|
|
8
8
|
unless defined?(::Occi::Core::VERSION)
|
9
9
|
VERSION = [
|