geekq / workflow

Ruby finite-state-machine-inspired API for modeling workflow
MIT License
1.75k stars 207 forks source link

Workflow 1.2 broken events method for me. #131

Closed gamov closed 9 years ago

gamov commented 9 years ago

wf < 1.2:

    @stock_transfer.current_state.events  #=> {:finalize=>finalize, :submit=>submit}

wf = 1.2:

    @stock_transfer.current_state.events  #=> {:finalize=>[finalize], :submit=>[submit]}

making things like:

   @stock_transfer.current_state.events[:finalize].transitions_to 
   #=> !! #<NoMethodError: undefined method `transitions_to' for [finalize]:Array>

commit c4869ffe18c027f49b2deb950016f06c05799898 works for me.

geekq commented 9 years ago

Sorry for that!

And thank you for your analysis!

This incompatible change to the metadata interface is likely due to feature #109. In the comments I expressed my concerns regarding incompatible changes, but eventually the advantage of the feature outweighted.

I'll add a more clear note regarding incompatibility to the Changelog.

You can either adjust your code to the new meta data API or stick to 1.1.0 in your Gemfile:

gem 'workflow', '~> 1.1.0'
geekq commented 9 years ago

Can you please check, if you can acquire familiar values by

@stock_transfer.current_state.events.flat #=> {:finalize=>finalize, :submit=>submit}

(adding flat call)

gamov commented 9 years ago

With >1.2

@stock_transfer.current_state.events.flat #=> [finalize, submit]

not the same hash as <1.2. But I guess I can change my code.