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

New, more functional DSL + remove of the need to declare guard_transition/1 #1

Merged
merged 6 commits into from
Dec 11, 2017

Conversation

joaomdmoura
Copy link
Owner

The current DSL on macros more than it should, this new DSL, is more function and also enables Machinery to have a default fallback behavior to the guard transitions.

The previous DSL used macros mores heavily what is known to be a bad
smell. This new DSL relies more on the Machinery module what will result into
a more clear and better documentation and a more usual implementation.
This new DSL still relies on macros but way less than the previous one.
This aims to enforce users of Machinery to properly declare at least the
one required signature of guard_transition/2
This removes the required need to have at least one guard_transition/2
function declared to pattern match into any state transition by using rescue
clauses that pattern match into UndefinedFunctionError and FunctionClauseError
with the correct expect signature of guard_transition.
lib/machinery.ex Outdated
# guard condition exists.
defp guard_transition(module, struct, next_state) do
try do
module.guard_transition(struct,next_state)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma

lib/machinery.ex Outdated
# transitions are permitted unless another existing
# guard condition exists.
defp guard_transition(module, struct, next_state) do
try do
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using an implicit try rather than explicit try.

@coveralls
Copy link

Coverage Status

Coverage decreased (-10.0%) to 90.0% when pulling 53d23e7 on new-dsl into b69f8c0 on master.

This adds new tests to cover the new behaviour of the new DSL, it also
switch a explicit rescue clause by a implicit one.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling a07f440 on new-dsl into b69f8c0 on master.

@joaomdmoura joaomdmoura merged commit 272e20f into master Dec 11, 2017
@joaomdmoura joaomdmoura deleted the new-dsl branch December 11, 2017 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants