state_manager 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
1
+ 0.2.10
@@ -13,7 +13,9 @@ module StateManager
13
13
  module ResourceMethods
14
14
 
15
15
  def self.included(base)
16
- # Make sure that the model is in a valid state before it is saved
16
+ base.after_initialize do
17
+ self.state_managers ||= {}
18
+ end
17
19
  base.before_validation do
18
20
  validate_states!
19
21
  end
@@ -52,7 +52,6 @@ module StateManager
52
52
  state_managers[property] = klass
53
53
  property_name = "#{property.to_s}_manager"
54
54
  define_method property_name do
55
- self.state_managers ||= {}
56
55
  state_manager = state_managers[property]
57
56
  unless state_manager
58
57
  state_manager = klass.new(self)
@@ -66,9 +65,13 @@ module StateManager
66
65
  end
67
66
 
68
67
  module InstanceMethods
68
+ def initialize(*args)
69
+ super(*args)
70
+ self.state_managers ||= {}
71
+ end
72
+
69
73
  # Ensures that all properties with state managers are in valid states
70
74
  def validate_states!
71
- self.state_managers ||= {}
72
75
  self.class.state_managers.each do |name, klass|
73
76
  # Simply ensuring that all of the state managers have been
74
77
  # instantiated will make the corresponding states valid
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "state_manager"
8
- s.version = "0.2.9"
8
+ s.version = "0.2.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gordon Hempton"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -271,7 +271,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
271
  version: '0'
272
272
  segments:
273
273
  - 0
274
- hash: 1941568341528515178
274
+ hash: -1972430724111836425
275
275
  required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  none: false
277
277
  requirements: