lib/acidic_job/arguments.rb in acidic_job-0.8.7 vs lib/acidic_job/arguments.rb in acidic_job-0.8.8

- old
+ new

@@ -16,7 +16,15 @@ def deserialize_global_id(hash) GlobalID::Locator.locate hash[GLOBALID_KEY] rescue ActiveRecord::RecordNotFound nil end + + # In order to allow our `NewRecordSerializer` a chance to work, we need to ensure that + # ActiveJob's first attempt to serialize an ActiveRecord model doesn't throw an exception. + def convert_to_global_id_hash(argument) + { GLOBALID_KEY => argument.to_global_id.to_s } + rescue URI::GID::MissingModelIdError + Serializers.serialize(argument) + end end end