Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing is_column_state? Functions #21

Open
h4cc opened this issue Nov 28, 2016 · 3 comments
Open

Introducing is_column_state? Functions #21

h4cc opened this issue Nov 28, 2016 · 3 comments

Comments

@h4cc
Copy link

h4cc commented Nov 28, 2016

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 added a commit to digimondo/ecto_state_machine that referenced this issue Nov 28, 2016
@yordis
Copy link

yordis commented Mar 18, 2017

@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.

@yordis
Copy link

yordis commented Mar 18, 2017

Nevermind, the whole implementation is based on this 😄

@asiniy
Copy link
Owner

asiniy commented Mar 18, 2017

@yordis if you know better way to implement this functionality, feel free to make a PR, or open an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants