stateflow 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ = Version 0.4.2
2
+ * Some code neatening by pedromenezes - Thanks!
3
+ * Added simple benchmark which is probably not accurate :)
4
+
1
5
  = Version 0.4.1
2
6
  * Removed the depreciation warnings - FINALLY :)
3
7
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('stateflow', '0.4.1') do |p|
5
+ Echoe.new('stateflow', '0.4.2') 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"
@@ -7,8 +7,8 @@ module Stateflow
7
7
  instance_eval(&machine)
8
8
  end
9
9
 
10
- def state_column(name = nil)
11
- @state_column ||= name.nil? ? :state : name
10
+ def state_column(name = :state)
11
+ @state_column ||= name
12
12
  end
13
13
 
14
14
  private
@@ -10,16 +10,16 @@ module Stateflow
10
10
 
11
11
  module InstanceMethods
12
12
  def load_from_persistence
13
- self.send machine.state_column.to_sym
13
+ send machine.state_column.to_sym
14
14
  end
15
15
 
16
- def save_to_persistence(new_state, options)
17
- self.send("#{machine.state_column}=".to_sym, new_state)
18
- self.save if options[:save]
16
+ def save_to_persistence(new_state, options = {})
17
+ send("#{machine.state_column}=".to_sym, new_state)
18
+ save if options[:save]
19
19
  end
20
20
 
21
21
  def ensure_initial_state
22
- send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if send(self.machine.state_column.to_s).blank?
22
+ send("#{machine.state_column.to_s}=", current_state.name.to_s) if send(machine.state_column.to_s).blank?
23
23
  end
24
24
  end
25
25
  end
@@ -10,16 +10,16 @@ module Stateflow
10
10
 
11
11
  module InstanceMethods
12
12
  def load_from_persistence
13
- self.send machine.state_column.to_sym
13
+ send machine.state_column.to_sym
14
14
  end
15
15
 
16
- def save_to_persistence(new_state, options)
17
- self.send("#{machine.state_column}=".to_sym, new_state)
18
- self.save if options[:save]
16
+ def save_to_persistence(new_state, options = {})
17
+ send("#{machine.state_column}=".to_sym, new_state)
18
+ save if options[:save]
19
19
  end
20
20
 
21
21
  def ensure_initial_state
22
- send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if self.send(self.machine.state_column.to_s).blank?
22
+ send("#{machine.state_column.to_s}=", current_state.name.to_s) if send(machine.state_column.to_s).blank?
23
23
  end
24
24
  end
25
25
  end
@@ -10,16 +10,16 @@ module Stateflow
10
10
 
11
11
  module InstanceMethods
12
12
  def load_from_persistence
13
- self.send machine.state_column.to_sym
13
+ send machine.state_column.to_sym
14
14
  end
15
15
 
16
16
  def save_to_persistence(new_state, options = {})
17
- self.send("#{machine.state_column}=".to_sym, new_state)
18
- self.save if options[:save]
17
+ send("#{machine.state_column}=".to_sym, new_state)
18
+ save if options[:save]
19
19
  end
20
20
 
21
21
  def ensure_initial_state
22
- send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if send(self.machine.state_column.to_s).blank?
22
+ send("#{machine.state_column.to_s}=", current_state.name.to_s) if send(machine.state_column.to_s).blank?
23
23
  end
24
24
  end
25
25
  end
@@ -6,7 +6,7 @@ module Stateflow
6
6
  @name = name
7
7
  @options = Hash.new
8
8
 
9
- instance_eval(&options) if options
9
+ instance_eval(&options) if block_given?
10
10
  end
11
11
 
12
12
  def enter(method = nil, &block)
@@ -22,7 +22,8 @@ module Stateflow
22
22
 
23
23
  to = execute_action(@decide, base)
24
24
 
25
- @to.include?(to) ? to : (raise NoStateFound.new("Decision did not return a state that was set in the 'to' argument"))
25
+ raise NoStateFound.new("Decision did not return a state that was set in the 'to' argument") unless @to.include?(to)
26
+ to
26
27
  end
27
28
 
28
29
  private
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{stateflow}
5
- s.version = "0.4.1"
5
+ s.version = "0.4.2"
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{2011-02-13}
9
+ s.date = %q{2011-04-07}
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 = ["CHANGELOG.rdoc", "README.rdoc", "lib/stateflow.rb", "lib/stateflow/event.rb", "lib/stateflow/exception.rb", "lib/stateflow/machine.rb", "lib/stateflow/persistence.rb", "lib/stateflow/persistence/active_record.rb", "lib/stateflow/persistence/mongo_mapper.rb", "lib/stateflow/persistence/mongoid.rb", "lib/stateflow/persistence/none.rb", "lib/stateflow/state.rb", "lib/stateflow/transition.rb"]
@@ -15,11 +15,10 @@ Gem::Specification.new do |s|
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Stateflow", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{stateflow}
18
- s.rubygems_version = %q{1.3.7}
18
+ s.rubygems_version = %q{1.6.2}
19
19
  s.summary = %q{State machine that allows dynamic transitions for business workflows}
20
20
 
21
21
  if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
22
  s.specification_version = 3
24
23
 
25
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stateflow
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 4
8
- - 1
9
- version: 0.4.1
4
+ prerelease:
5
+ version: 0.4.2
10
6
  platform: ruby
11
7
  authors:
12
8
  - Ryan Oberholzer
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-02-13 00:00:00 +00:00
13
+ date: 2011-04-07 00:00:00 +02:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 0
31
- - 0
32
24
  version: 2.0.0
33
25
  type: :development
34
26
  version_requirements: *id001
@@ -40,8 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
35
  version: "0"
46
36
  type: :development
47
37
  version_requirements: *id002
@@ -53,12 +43,6 @@ dependencies:
53
43
  requirements:
54
44
  - - ">="
55
45
  - !ruby/object:Gem::Version
56
- segments:
57
- - 2
58
- - 0
59
- - 0
60
- - beta
61
- - 20
62
46
  version: 2.0.0.beta.20
63
47
  type: :development
64
48
  version_requirements: *id003
@@ -70,8 +54,6 @@ dependencies:
70
54
  requirements:
71
55
  - - ">="
72
56
  - !ruby/object:Gem::Version
73
- segments:
74
- - 0
75
57
  version: "0"
76
58
  type: :development
77
59
  version_requirements: *id004
@@ -141,22 +123,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
123
  requirements:
142
124
  - - ">="
143
125
  - !ruby/object:Gem::Version
144
- segments:
145
- - 0
146
126
  version: "0"
147
127
  required_rubygems_version: !ruby/object:Gem::Requirement
148
128
  none: false
149
129
  requirements:
150
130
  - - ">="
151
131
  - !ruby/object:Gem::Version
152
- segments:
153
- - 1
154
- - 2
155
132
  version: "1.2"
156
133
  requirements: []
157
134
 
158
135
  rubyforge_project: stateflow
159
- rubygems_version: 1.3.7
136
+ rubygems_version: 1.6.2
160
137
  signing_key:
161
138
  specification_version: 3
162
139
  summary: State machine that allows dynamic transitions for business workflows