occi-core 5.0.0.beta.8 → 5.0.0.beta.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 349e8ab2c6ff7e544c14a8e14beba5408cec7c6e
4
- data.tar.gz: a843c93b9d2b35993c57b76d39ac8781eb8fbc5a
3
+ metadata.gz: ccf964beebc12970fdcaf0ab624593f4bb73b74f
4
+ data.tar.gz: 2d8c4b87e3c5948beef5be425e5042478f4734c7
5
5
  SHA512:
6
- metadata.gz: a41664f161e846c1c60832b4aa844d7e6a78980d4d6a34a48b9d15be89c0750f68251a1bb4c6d438ec48b9c869dfcc90a41994027df9e9ac14d06e1f307fcc48
7
- data.tar.gz: bb88f43ae654c457706a047d105bc3a446dedf0460217d4fba10a4ae8e2a7124f3dcdc8e9e6ce23cb62afcd7b2168a139d29f01b39717afbee390e00c0cbe186
6
+ metadata.gz: 7ad87812e470b99636a412f54b09e881d30acbaa01cb371f52f72821cf1166a76cbcf125ab610e292b9443d3dfeb14053acd0232d709889ec16ed03c9e5382a4
7
+ data.tar.gz: b8be9a5d023b5a944a756f19ae8ff5756671d46c48f910377729d8ba5a51bdd6f1bd7741540203db868c9cf15e3e9d4538a6c466c457d1cb23b6facf86f50fc8
@@ -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
@@ -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.8'.freeze # use `nil` for production releases
6
+ STAGE_VERSION = 'beta.9'.freeze # use `nil` for production releases
7
7
 
8
8
  unless defined?(::Occi::Core::VERSION)
9
9
  VERSION = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occi-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta.8
4
+ version: 5.0.0.beta.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Parak