Class: Occi::Core::Parsers::Json::ActionInstance
- Inherits:
-
Object
- Object
- Occi::Core::Parsers::Json::ActionInstance
- Extended by:
- Helpers::RawJsonParser
- Includes:
- Helpers::ErrorHandler, Yell::Loggable
- Defined in:
- lib/occi/core/parsers/json/action_instance.rb
Overview
Static parsing class responsible for extracting action instances from JSON. Class supports ‘application/json’ via ‘json`. No other formats are supported.
Class Method Summary collapse
-
.json(body, model) ⇒ Occi::Core::ActionInstance
Parses action instances.
Methods included from Helpers::RawJsonParser
Methods included from Helpers::ErrorHandler
Class Method Details
.json(body, model) ⇒ Occi::Core::ActionInstance
Parses action instances. Internal references between objects are converted from strings to actual objects. Actions have to be declared in the provided model.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/occi/core/parsers/json/action_instance.rb', line 21 def json(body, model) parsed = raw_hash(body) action = handle(Occi::Core::Errors::ParsingError) { model.find_by_identifier! parsed[:action] } logger.debug { "Identified #{action.class}[#{action.identifier}]" } ai = Occi::Core::ActionInstance.new(action: action) ep = Entity.new(model: model) ep.set_attributes!(ai, parsed[:attributes]) if parsed[:attributes] logger.debug { "Parsed into ActionInstance #{ai.inspect}" } ai end |