app/models/apidae/selection.rb in apidae-0.9.17 vs app/models/apidae/selection.rb in apidae-0.9.18
- old
+ new
@@ -86,11 +86,11 @@
def api_object(apidae_obj_id)
query_args = build_args(OBJECTS_ENDPOINT, {obj_ids: [apidae_obj_id], fields: ["@all"]})
query_objects_api(query_args, true)
end
- def refresh_obj(apidae_obj_id)
+ def add_or_refresh_obj(apidae_obj_id)
if apidae_project
res = api_object(apidae_obj_id)
if res[:results] && res[:results].length == 1
obj_data = res[:results].first.deep_symbolize_keys
obj = Obj.find_by_apidae_id(apidae_obj_id)
@@ -98,9 +98,11 @@
refreshed = Obj.update_object(obj, obj_data, apidae_project.locales, apidae_project.versions)
if refreshed && Rails.application.config.respond_to?(:apidae_obj_refresh_callback)
Rails.application.config.apidae_obj_refresh_callback.call(apidae_obj_id)
end
refreshed
+ else
+ Obj.add_object(obj_data, apidae_project.locales, apidae_project.versions)
end
end
end
end