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:
= Copier Copié!

installation:
=

Versions:

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

Dépendances de Development (2):

rake >= 0
rspec ~> 2.0

Propriétaires:

Auteurs:

  • Ivan Navarrete, Kim Burgestrand

Total de contrôle SHA 256:

= Copier Copié!

Total de téléchargements 10 111

Pour cette version 2 996

License:

aucune

Version de Ruby requise: None

Liens: