stateflow 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -13,4 +13,3 @@ lib/stateflow/persistence/active_record.rb
13
13
  lib/stateflow/persistence/mongo_mapper.rb
14
14
  lib/stateflow/state.rb
15
15
  lib/stateflow/transition.rb
16
- stateflow.gemspec
@@ -7,18 +7,30 @@
7
7
 
8
8
  This is the basics of the gem. THIS IS NOT PRODUCTION READY UNTIL TESTS ARE DONE. Please check out the examples directory for usage until this README gets fleshed out. Feel free to fork and modify as you please.
9
9
 
10
+ == INSTALL
11
+
12
+ gem install stateflow
13
+
10
14
  == Usage
11
15
 
12
- Stateflow supports persistence with MongoMapper, and ActiveRecord. Adding more is really basic, please request any if needed.
16
+ As you can see below, Stateflow's API is very similar to AASM, but allows for a more dynamic state transition flow. Stateflow supports persistence/storage with MongoMapper, and ActiveRecord. Request any others or push them to me.
13
17
 
14
18
  Stateflow defaults to ActiveRecord but you can set the persistence layer with:
15
19
 
16
20
  Stateflow.persistence = :mongo_mapper
17
21
  OR
18
22
  Stateflow.persistence = :active_record
23
+
24
+ Stateflow allows dynamic :to transitions with :decide. The result :decide returns needs to be one of the states listed in the :to array, otherwise it wont allow the transition. Please view the advanced example below for usage.
25
+
26
+ You can set the default column with the state_column function in the stateflow block. The default state column is "state".
27
+
28
+ state_column :state
19
29
 
20
30
  == Basic Example
21
31
 
32
+ Please note these examples need a persistence layer to operate. I might allow non persistent stateflows in the future.
33
+
22
34
  require 'rubygems'
23
35
  require 'stateflow'
24
36
 
@@ -89,12 +101,6 @@ OR
89
101
  end
90
102
  end
91
103
 
92
- As you can see Stateflow allows dynamic :to transitions. *This allows your flows to be dynamic, and is the main feature of this gem over the others.*
93
-
94
- You can set the default column with the state_column function in the stateflow block. The default state column is ":state".
95
-
96
- state_column :state
97
-
98
104
  == Note on Patches/Pull Requests
99
105
 
100
106
  * Fork the project.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('stateflow', '0.0.3') do |p|
5
+ Echoe.new('stateflow', '0.0.4') do |p|
6
6
  p.description = "State machine that allows dynamic transitions for business workflows"
7
7
  p.url = "http://github.com/ryanza/stateflow"
8
8
  p.author = "Ryan Oberholzer"
@@ -1,8 +1,8 @@
1
1
  module Stateflow
2
2
  def self.included(base)
3
3
  base.send :include, InstanceMethods
4
- Stateflow::Persistence.set(base)
5
4
  base.extend ClassMethods
5
+ Stateflow::Persistence.set(base)
6
6
  end
7
7
 
8
8
  def self.persistence
@@ -2,7 +2,6 @@ module Stateflow
2
2
  module Persistence
3
3
  module MongoMapper
4
4
  def self.install(base)
5
- base.send :key, self.machine.state_column.to_sym, String
6
5
  base.before_validation_on_create :ensure_initial_state
7
6
  base.send :include, InstanceMethods
8
7
  end
@@ -17,7 +16,7 @@ module Stateflow
17
16
  end
18
17
 
19
18
  def ensure_initial_state
20
- send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if send(self.machine.state_column.to_s).blank?
19
+ send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if self.send(self.machine.state_column.to_s).blank?
21
20
  end
22
21
  end
23
22
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{stateflow}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ryan Oberholzer"]
9
- s.date = %q{2010-03-24}
9
+ s.date = %q{2010-04-15}
10
10
  s.description = %q{State machine that allows dynamic transitions for business workflows}
11
11
  s.email = %q{ryan@platform45.com}
12
12
  s.extra_rdoc_files = ["README.rdoc", "lib/stateflow.rb", "lib/stateflow/event.rb", "lib/stateflow/machine.rb", "lib/stateflow/persistence.rb", "lib/stateflow/persistence/active_record.rb", "lib/stateflow/persistence/mongo_mapper.rb", "lib/stateflow/state.rb", "lib/stateflow/transition.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stateflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Oberholzer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-24 00:00:00 +02:00
12
+ date: 2010-04-15 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15