Class: Occi::Core::Renderers::Json::Base

Inherits:
Object
  • Object
show all
Includes:
Yell::Loggable
Defined in:
lib/occi/core/renderers/json/base.rb

Overview

Implements methods common to all JSON-based renderers. This class is not meant to be used directly, only as a parent to other type-specific rendering classes.

Author:

Constant Summary collapse

DELEGATED =

Shortcuts to interesting object attributes, always prefixed with `object_`

%i[
  respond_to? send source target summary kind parent action
  attributes actions mixins depends applies rel empty?
  categories entities resources links action_instances
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, options) ⇒ Base

Constructs a renderer instance for the given object.


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

def initialize(object, options)
  @object = object
  @options = options
end

Instance Attribute Details

#objectObject

instance to be rendered


13
14
15
# File 'lib/occi/core/renderers/json/base.rb', line 13

def object
  @object
end

#optionsHash

additional rendering options


13
14
15
# File 'lib/occi/core/renderers/json/base.rb', line 13

def options
  @options
end

Instance Method Details

#renderString

Renders the given object to `JSON`.


39
40
41
# File 'lib/occi/core/renderers/json/base.rb', line 39

def render
  render_hash.to_json
end