require 'rest_client' module RailsConnector # connects the cloud connector to the connector service class ServiceCmsBackend < CmsBackend def begin_caching # TODO end def end_caching # TODO end def caching? # TODO end def find_obj_data_by(workspace, index, keys) raw_data = ConnectorService.query( "objs/query", :queries => keys.map do |key| { :type => index, :param => key } end, :workspace => workspace.id, :revision => workspace.revision.id ) objs = {} raw_data["objs"].each do |obj| objs[obj["_id"].first] = obj end raw_data["results"].map do |query| query["refs"].map do |obj_ref| id = obj_ref["id"] # TODO fetch missing ObjData from Service raw_obj_data = objs[id] or raise "Data for Obj with id #{id} missing!" ObjDataFromService.new(raw_obj_data) end end end end end