Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
bug: Change _build_model to take a dictionary. (#10)
Browse files Browse the repository at this point in the history
* bug: Change _build_model to take a dictionary.

Since _wrap_on_message will always load the json data into a dictionary
before passing it to the underlying implementation there was no need for
_build_model to attempt to load the input as a json string.

* fixup! bug: Change _build_model to take a dictionary.
  • Loading branch information
ashcrow authored and mbarnes committed Sep 29, 2016
1 parent b95ef09 commit dd30d7d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/commissaire_service/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import fnmatch
import importlib
import json

import commissaire.models as models

Expand Down Expand Up @@ -108,19 +107,19 @@ def register_store_handler(self, config):
self._manager.register_store_handler(
handler_type, config, *matched_types)

def _build_model(self, model_type_name, model_json_data):
def _build_model(self, model_type_name, model_kwargs):
"""
Builds a model instance from a type name and JSON representation.
Builds a model instance from a type name and kwargs.
:param model_type_name: Model type for the JSON data
:type model_type_name: str
:param model_json_data: JSON representation of a model
:type model_json_data: str
:param model_kwargs: Keyword args to pass to the model
:type model_kwargs: dict
:returns: a model instance
:rtype: commissaire_service.storage.models.Model
"""
model_type = self._model_types[model_type_name]
return model_type.new(**json.loads(model_json_data))
return model_type.new(**model_kwargs)

def on_save(self, message, model_type_name, model_json_data):
"""
Expand Down

0 comments on commit dd30d7d

Please sign in to comment.