diff --git a/lib/avrora/avro_type_converter/primitive_into_logical.ex b/lib/avrora/avro_type_converter/primitive_into_logical.ex index bca9af70..dd8055d3 100644 --- a/lib/avrora/avro_type_converter/primitive_into_logical.ex +++ b/lib/avrora/avro_type_converter/primitive_into_logical.ex @@ -132,5 +132,5 @@ defmodule Avrora.AvroTypeConverter.PrimitiveIntoLogical do do: {:error, %Avrora.Errors.ConfigurationError{code: :missing_decimal_lib}} end - defp enabled, do: Config.self().decode_logical_types() == true + defp enabled, do: Config.self().cast_logical_types() == true end diff --git a/lib/avrora/client.ex b/lib/avrora/client.ex index b807a683..89431c64 100644 --- a/lib/avrora/client.ex +++ b/lib/avrora/client.ex @@ -127,7 +127,7 @@ defmodule Avrora.Client do def registry_schemas_autoreg, do: get(@opts, :registry_schemas_autoreg, true) def convert_null_values, do: get(@opts, :convert_null_values, true) def convert_map_to_proplist, do: get(@opts, :convert_map_to_proplist, false) - def decode_logical_types, do: get(@opts, :decode_logical_types, true) + def cast_logical_types, do: get(@opts, :cast_logical_types, true) def names_cache_ttl, do: get(@opts, :names_cache_ttl, :infinity) def decoder_hook, do: get(@opts, :decoder_hook, fn _, _, data, fun -> fun.(data) end) def file_storage, do: unquote(:"Elixir.#{module}.Storage.File") diff --git a/lib/avrora/config.ex b/lib/avrora/config.ex index 4da775e5..071b74b1 100644 --- a/lib/avrora/config.ex +++ b/lib/avrora/config.ex @@ -14,7 +14,7 @@ defmodule Avrora.Config do * `convert_map_to_proplist` bring back old behavior and configure decoding AVRO map-type as proplist, default `false` TODO Rename into cast_logical_types TODO Introduce configurable list of logical type casting - * `decode_logical_types` convert logical AVRO primitive or complex type into corresponding Elixir representation, default `true` + * `cast_logical_types` convert logical AVRO primitive or complex type into corresponding Elixir representation, default `true` * `names_cache_ttl` duration to cache global schema names millisecods, default `:infinity` * `decoder_hook` function to amend decoded payload, default `fn _, _, data, fun -> fun.(data) end` @@ -34,7 +34,7 @@ defmodule Avrora.Config do @callback registry_schemas_autoreg :: boolean() @callback convert_null_values :: boolean() @callback convert_map_to_proplist :: boolean() - @callback decode_logical_types :: boolean() + @callback cast_logical_types :: boolean() @callback names_cache_ttl :: integer() | atom() @callback decoder_hook :: (any(), any(), any(), any() -> any()) @callback file_storage :: module() @@ -70,7 +70,7 @@ defmodule Avrora.Config do def convert_map_to_proplist, do: get_env(:convert_map_to_proplist, false) @doc false - def decode_logical_types, do: get_env(:decode_logical_types, true) + def cast_logical_types, do: get_env(:cast_logical_types, true) @doc false def names_cache_ttl, do: get_env(:names_cache_ttl, :infinity) diff --git a/test/avrora/avro_type_converter/primitive_into_logical_test.exs b/test/avrora/avro_type_converter/primitive_into_logical_test.exs index e58579f4..3c17ab96 100644 --- a/test/avrora/avro_type_converter/primitive_into_logical_test.exs +++ b/test/avrora/avro_type_converter/primitive_into_logical_test.exs @@ -13,7 +13,7 @@ defmodule Avrora.AvroTypeConverter.PrimitiveIntoLogicalTest do describe "convert/2" do test "when logical types must be kept as is" do - stub(Avrora.ConfigMock, :decode_logical_types, fn -> false end) + stub(Avrora.ConfigMock, :cast_logical_types, fn -> false end) {:ok, decoded} = Codec.Plain.decode(date_message(), schema: schema(date_json())) diff --git a/test/avrora/codec/plain_test.exs b/test/avrora/codec/plain_test.exs index 894d2950..1199b4dc 100644 --- a/test/avrora/codec/plain_test.exs +++ b/test/avrora/codec/plain_test.exs @@ -137,7 +137,7 @@ defmodule Avrora.Codec.PlainTest do end test "when decoding message and logical types must be as is" do - stub(Avrora.ConfigMock, :decode_logical_types, fn -> false end) + stub(Avrora.ConfigMock, :cast_logical_types, fn -> false end) {:ok, decoded} = Codec.Plain.decode(convertable_message(), schema: convertable_schema()) @@ -146,7 +146,7 @@ defmodule Avrora.Codec.PlainTest do test "when decoding message and all types must be as is" do stub(Avrora.ConfigMock, :convert_null_values, fn -> false end) - stub(Avrora.ConfigMock, :decode_logical_types, fn -> false end) + stub(Avrora.ConfigMock, :cast_logical_types, fn -> false end) {:ok, decoded} = Codec.Plain.decode(convertable_message(), schema: convertable_schema()) diff --git a/test/support/config.ex b/test/support/config.ex index d40ba988..8f9d3815 100644 --- a/test/support/config.ex +++ b/test/support/config.ex @@ -52,7 +52,7 @@ defmodule Support.Config do @impl true def convert_map_to_proplist, do: false @impl true - def decode_logical_types, do: true + def cast_logical_types, do: true @impl true def file_storage, do: Avrora.Storage.FileMock @impl true