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:
= 複製 已複製

安裝:
=

版本列表:

  1. 1.1.0 - October 28, 2015 (10.0 KB)
  2. 1.0.1 - November 15, 2012 (8.5 KB)
  3. 1.0.0 - November 15, 2012 (9.0 KB)

Development 相依性套件 (2):

rake >= 0
rspec ~> 2.0

擁有者:

作者:

  • Ivan Navarrete, Kim Burgestrand

SHA 256 總和檢查碼:

= 複製 已複製

總下載次數 10,111

這個版本 2,996

授權:

Ruby 版本需求:

相關連結: