From 56260a31f90621bdb537cb34681dfb7e499cffc3 Mon Sep 17 00:00:00 2001 From: Unnawut Leepaisalsuwanna Date: Tue, 6 Mar 2018 18:13:40 +0700 Subject: [PATCH 1/2] Update underscore/1 to support Elixir 1.6's regex --- lib/ex_machina/strategy.ex | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/ex_machina/strategy.ex b/lib/ex_machina/strategy.ex index f3dea21..9e51dfa 100644 --- a/lib/ex_machina/strategy.ex +++ b/lib/ex_machina/strategy.ex @@ -142,9 +142,5 @@ defmodule ExMachina.Strategy do |> String.to_atom end - defp underscore(name) do - ~r/(?=[A-Z])/ - |> Regex.split(name) - |> Enum.join("_") - end + defp underscore(name), do: Regex.replace(~r/(? Date: Tue, 6 Mar 2018 22:39:43 +0700 Subject: [PATCH 2/2] Use Macro.underscore/1 instead of a custom implementation --- lib/ex_machina/strategy.ex | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ex_machina/strategy.ex b/lib/ex_machina/strategy.ex index 9e51dfa..cbd0129 100644 --- a/lib/ex_machina/strategy.ex +++ b/lib/ex_machina/strategy.ex @@ -137,10 +137,8 @@ defmodule ExMachina.Strategy do struct_name |> Module.split |> List.last - |> underscore + |> Macro.underscore |> String.downcase |> String.to_atom end - - defp underscore(name), do: Regex.replace(~r/(?