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:
=

Installeer:
=

Versies:

  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)

Development afhankelijkheden (2):

rake >= 0
rspec ~> 2.0

Eigenaren:

Authors:

  • Ivan Navarrete, Kim Burgestrand

SHA 256 checksum:

=

Total downloads 10.271

Voor deze versie 3.041

Versie vrijgegeven:

Licenties:

N/A

Required Ruby Version: Geen

Links: