Module: Occi::Api::Client::Base::ProtectedHelpers
- Included in:
- ClientBase
- Defined in:
- lib/occi/api/client/base/protected_helpers.rb
Instance Method Summary collapse
-
#get_endpoint_uri(endpoint) ⇒ URI
Checks whether the given endpoint URI is valid and converts it to a URI instance.
-
#get_logger(log_options) ⇒ Occi::Api::Log
Sets the logger and log levels.
-
#get_model(model_collection) ⇒ Occi::Model
Creates an Occi::Model from data retrieved from the server.
-
#get_os_tpl_mixins_ary ⇒ Array
Returns mixin type identifiers for os_tpl mixins in an array.
-
#get_resource_tpl_mixins_ary ⇒ Array
Returns mixin type identifiers for resource_tpl mixins in an array.
Instance Method Details
#get_endpoint_uri(endpoint) ⇒ URI
Checks whether the given endpoint URI is valid and converts it to a URI instance.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/occi/api/client/base/protected_helpers.rb', line 33 def get_endpoint_uri(endpoint) unless endpoint =~ URI::ABS_URI raise "Endpoint not a valid absolute URI! #{endpoint.inspect}" end # normalize URIs, remove trailing slashes endpoint = URI(endpoint) endpoint.path = endpoint.path.gsub(/\/+/, '/').chomp('/') endpoint.query = nil endpoint end |
#get_logger(log_options) ⇒ Occi::Api::Log
Sets the logger and log levels. This allows users to pass existing logger instances to the rOCCI client.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/occi/api/client/base/protected_helpers.rb', line 14 def get_logger() unless [:logger].kind_of?(Occi::Api::Log) logger = Occi::Api::Log.new([:out]) logger.level = [:level] else logger = [:logger] end logger end |
#get_model(model_collection) ⇒ Occi::Model
Creates an Occi::Model from data retrieved from the server.
54 55 56 57 |
# File 'lib/occi/api/client/base/protected_helpers.rb', line 54 def get_model(model_collection) # build model Occi::Model.new(model_collection) end |
#get_os_tpl_mixins_ary ⇒ Array
Returns mixin type identifiers for os_tpl mixins in an array.
63 64 65 66 |
# File 'lib/occi/api/client/base/protected_helpers.rb', line 63 def get_os_tpl_mixins_ary mixins = get_os_tpls mixins.to_a.collect { |m| m.type_identifier } end |
#get_resource_tpl_mixins_ary ⇒ Array
Returns mixin type identifiers for resource_tpl mixins in an array.
72 73 74 75 |
# File 'lib/occi/api/client/base/protected_helpers.rb', line 72 def get_resource_tpl_mixins_ary mixins = get_resource_tpls mixins.to_a.collect { |m| m.type_identifier } end |