apollo 1.3.0.beta.3 → 1.3.0.beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.beta.3
1
+ 1.3.0.beta.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{apollo}
8
- s.version = "1.3.0.beta.3"
8
+ s.version = "1.3.0.beta.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Travis D. Warlick, Jr.", "Charlie Savage", "Blake Chambers"]
12
- s.date = %q{2010-06-01}
12
+ s.date = %q{2010-06-15}
13
13
  s.email = ["warlickt@operissystems.com", "cfis@zerista.com", "chambb1@gmail.com"]
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -36,6 +36,8 @@ module Apollo
36
36
 
37
37
  class NoTransitionAllowed < Exception; end
38
38
 
39
+ class StateNotFound < Exception; end
40
+
39
41
  class ApolloError < Exception; end
40
42
 
41
43
  class ApolloDefinitionError < Exception; end
@@ -93,6 +95,10 @@ module Apollo
93
95
  @current_state = new_value.to_s
94
96
  end
95
97
 
98
+ def default_state
99
+ self.class.state_machine.default_state
100
+ end
101
+
96
102
  def halted?
97
103
  @halted
98
104
  end
@@ -211,7 +217,7 @@ module Apollo
211
217
  #
212
218
  # Default ActiveRecord implementation uses a 'current_state' database column.
213
219
  def load_current_state
214
- @current_state if instance_variable_defined? :@current_state
220
+ (instance_variable_defined?(:@current_state) ? @current_state : nil) || default_state
215
221
  end
216
222
  end
217
223
 
@@ -2,11 +2,14 @@ module Apollo
2
2
  module ActiveRecordExtensions
3
3
  module InstanceMethods
4
4
  def load_current_state
5
- if self.class.persist_string_state_name?
5
+ result = if self.class.persist_string_state_name?
6
6
  read_attribute(self.class.current_state_column)
7
7
  else
8
- self.class.state_id_to_name(read_attribute(self.class.current_state_id_column))
8
+ id = read_attribute(self.class.current_state_id_column)
9
+ self.class.state_id_to_name(id) if id
9
10
  end
11
+
12
+ result || self.default_state
10
13
  end
11
14
 
12
15
  def current_state=(new_value)
@@ -9,6 +9,16 @@ module Apollo
9
9
  instance_eval(&specification)
10
10
  end
11
11
 
12
+ # TODO - Possibly allow passing of a block here to
13
+ # allow users more control over the default state
14
+ # under certain conditions
15
+ def default_state(state_name = nil)
16
+ return @default_state unless state_name
17
+
18
+ validate_state_name(state_name)
19
+ @default_state = state_name
20
+ end
21
+
12
22
  private
13
23
 
14
24
  def state(name, meta = {:meta => {}}, &events_and_etc)
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196405
4
+ hash: 62196411
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
10
  - beta
11
- - 3
12
- version: 1.3.0.beta.3
11
+ - 4
12
+ version: 1.3.0.beta.4
13
13
  platform: ruby
14
14
  authors:
15
15
  - Travis D. Warlick, Jr.
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-06-01 00:00:00 -05:00
22
+ date: 2010-06-15 00:00:00 -05:00
23
23
  default_executable:
24
24
  dependencies: []
25
25