Module: Occi::Core::Renderers::Json::Instance

Included in:
Link, Resource
Defined in:
lib/occi/core/renderers/json/instance.rb

Overview

Implements methods needed to render multiple instance types to JSON-based renderings.

Author:

Instance Method Summary collapse

Instance Method Details

#render_attributes_hashObject

:nodoc:


32
33
34
# File 'lib/occi/core/renderers/json/instance.rb', line 32

def render_attributes_hash
  Attributes.new(object_attributes, options).render_hash
end

#render_instance_hashObject

:nodoc:


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/occi/core/renderers/json/instance.rb', line 13

def render_instance_hash
  hsh = {}

  hsh[:kind] = object_kind.to_s
  %i[mixins actions].each do |symbol|
    hsh[symbol] = object_send(symbol).collect(&:to_s) unless object_send(symbol).blank?
  end

  hsh[:attributes] = render_attributes_hash unless object_attributes.blank?

  %i[id title].each do |symbol|
    next unless object_send(symbol)
    hsh[symbol] = object_send(symbol)
  end

  hsh
end