ecto_state_machine
ecto_state_machine copied to clipboard
Introducing `is_column_state?` Functions
It would be cool, to have a praedicate to check if a column is in a state, like: is_update_successfull?
Code to use here:
states
|> Enum.each(fn(state) ->
def unquote(:"is_#{column}_#{state}?")(model) do
:"#{Map.get(model, unquote(column))}" == unquote(state)
end
end)
@h4cc is there any way to avoid the meta-programming? Instead of use like is_#{column}_#{state}?
create a function that receive a state
and column
and checks it?
I wouldn't push for this practices when we can avoid it.
Nevermind, the whole implementation is based on this 😄
@yordis if you know better way to implement this functionality, feel free to make a PR, or open an issue