Module: Occi::Api::Client::Base::KindMethods
- Included in:
- ClientBase
- Defined in:
- lib/occi/api/client/base/kind_methods.rb
Instance Method Summary collapse
-
#get_kind_type_identifier(type) ⇒ String?
Retrieves available kind type identifier for the given kind type.
-
#get_kind_type_identifiers ⇒ Array<String>
Retrieves all available kind type identifiers.
-
#get_kind_type_identifiers_related_to(type_identifier) ⇒ Array<String>
Retrieves all kind type identifiers related to a given type identifier.
-
#get_kind_types ⇒ Array<String>
Retrieves all available kind types.
Instance Method Details
#get_kind_type_identifier(type) ⇒ String?
Retrieves available kind type identifier for the given kind type.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/occi/api/client/base/kind_methods.rb', line 53 def get_kind_type_identifier(type) return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/')) kinds = @model.kinds.to_a.select { |k| k.term == type } tis = kinds.collect { |k| k.type_identifier } tis.uniq! if tis.length > 1 raise Occi::Api::Client::Errors::AmbiguousNameError, "Kind type #{type.inspect} is ambiguous, use a type identifier!" end tis.first end |
#get_kind_type_identifiers ⇒ Array<String>
Retrieves all available kind type identifiers.
41 42 43 |
# File 'lib/occi/api/client/base/kind_methods.rb', line 41 def get_kind_type_identifiers @model.kinds.to_a.collect { |kind| kind.type_identifier } end |
#get_kind_type_identifiers_related_to(type_identifier) ⇒ Array<String>
Retrieves all kind type identifiers related to a given type identifier
16 17 18 19 20 |
# File 'lib/occi/api/client/base/kind_methods.rb', line 16 def (type_identifier) Occi::Api::Log.debug("Getting kind type identifiers related to #{type_identifier.inspect}") collection = @model.get(type_identifier) collection.kinds.to_a.collect { |kind| kind.type_identifier } end |
#get_kind_types ⇒ Array<String>
Retrieves all available kind types.
28 29 30 |
# File 'lib/occi/api/client/base/kind_methods.rb', line 28 def get_kind_types @model.kinds.to_a.collect { |kind| kind.term } end |