-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
| # TODO:: try to improve this double parsing |
require "../utilities/*"
module PlaceOS::Api
abstract class Application < ActionController::Base
macro inherited
Log = ::PlaceOS::Api::Log.for(self)
end
# Customise the request body parser
add_parser("application/json") do |klass, body_io|
json = body_io.gets_to_end
object = klass.from_json(json)
# TODO:: try to improve this double parsing
if object.is_a?(::PlaceOS::Model::ModelBase)
object = object.class.new
# we clear the changes information so we can track what was assigned from the JSON
object.clear_changes_information
object.assign_attributes_from_json(json)
end
object
end
# Helpers for controller responses
include Utils::Responders