Class: Occi::Core::Renderers::Json::Link
- Includes:
- Instance
- Defined in:
- lib/occi/core/renderers/json/link.rb
Overview
Implements routines required to render ‘Occi::Core::Link` and its subclasses to a JSON-based representation.
Constant Summary collapse
- COMPUTE_KIND =
Note: this is a hack for typing ‘source` on known Compute links
'http://schemas.ogf.org/occi/infrastructure#compute'.freeze
- COMPUTY_LINKS =
%w[ http://schemas.ogf.org/occi/infrastructure#networkinterface http://schemas.ogf.org/occi/infrastructure#storagelink http://schemas.ogf.org/occi/infrastructure#securitygrouplink ].freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#render_hash ⇒ Object
:nodoc:.
-
#typed_uri_hash(attribute, type) ⇒ Object
:nodoc:.
Methods included from Instance
#render_attributes_hash, #render_instance_hash
Methods inherited from Base
Constructor Details
This class inherits a constructor from Occi::Core::Renderers::Json::Base
Instance Method Details
#render_hash ⇒ Object
:nodoc:
24 25 26 27 28 29 |
# File 'lib/occi/core/renderers/json/link.rb', line 24 def render_hash base = render_instance_hash base[:source] = typed_uri_hash(object_source, :source) if object_source base[:target] = typed_uri_hash(object_target, :target) if object_target base end |
#typed_uri_hash(attribute, type) ⇒ Object
:nodoc:
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/occi/core/renderers/json/link.rb', line 32 def typed_uri_hash(attribute, type) hsh = { location: attribute.to_s } known_kind = object_send("#{type}_kind") hsh[:kind] = known_kind.identifier if known_kind # Note: this is a hack for typing `source` on known Compute links if hsh[:kind].blank? && type == :source && COMPUTY_LINKS.include?(object_kind.identifier) hsh[:kind] = COMPUTE_KIND end hsh end |