RubyGems Navigation menu

nanomachine 1.0.0

A really tiny state machine for ruby. No events, only accepted transitions and transition callbacks. The difference between Nanomachine, and otherwise known Micromachine (https://rubygems.org/gems/micromachine) is that Micromachine transitions to new states in response to events; multiple events can transition between the two same states. Nanomachine, on the other hand, does not care about events, and only needs the state you want to be in after successful transition. Nanomachine can be used in any ruby project, and have no runtime dependencies. Example: state_machine = Nanomachine.new("unpublished") do |fsm| fsm.transition("published", %w[unpublished processing removed]) fsm.transition("unpublished", %w[published processing removed]) fsm.transition("processing", %w[published unpublished]) fsm.transition("removed", []) # defined for being explicit fsm.on_transition do |(from_state, to_state)| update_column(:state, to_state) end end if state_machine.transition_to("published") puts "Publish success!" else puts "Publish failure! We’re in #{state_machine.state}." end

Gemfile:
=

instalar:
=

Versiones:

  1. 1.1.0 October 28, 2015 (10 KB)
  2. 1.0.1 November 15, 2012 (8,5 KB)
  3. 1.0.0 November 15, 2012 (9 KB)

dependencias de Development (2):

rake >= 0
rspec ~> 2.0

Propietarios:

Autores:

  • Ivan Navarrete, Kim Burgestrand

SHA 256 checksum:

=

Total de descargas 10.271

Para esta versión 3.041

Versión publicada:

Licencias:

N/A

Versión de Ruby requerida: Ninguno

Enlace: