class Occi::Core::Parsers::Json::Category

Static parsing class responsible for extracting categories from JSON. Class supports 'application/json' via `json`. No other formats are supported.

@author Boris Parak <parak@cesnet.cz>

Constants

APPLIES_KEY
DELEGATED

Shortcuts to interesting methods on logger

DEPENDS_KEY
PARENT_KEY

Hash constants for ParserDereferencer

TYPECASTER_HASH

Typecasting lambdas

Public Class Methods

json(body, model) click to toggle source

Parses categories into instances of subtypes of `Occi::Core::Category`. Internal references between objects are converted from strings to actual objects. Categories provided in the model will be reused but have to be declared in the parsed model as well.

@param body [String] JSON body for parsing @param model [Occi::Core::Model] model with existing categories @return [Occi::Core::Model] model with all known category instances

# File lib/occi/core/parsers/json/category.rb, line 41
def json(body, model)
  parsed = raw_hash(body)
  instantiate_hashes! parsed, model
  logger.debug "Parsed into raw hashes #{parsed.inspect}" if logger_debug?

  raw_categories = [parsed[:kinds], parsed[:mixins]].flatten.compact
  dereference_identifiers! model.categories, raw_categories

  logger.debug "Returning (updated) model #{model.inspect}" if logger_debug?
  model
end