transitions 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ # 1.0.3
2
+
3
+ (troessner) Make sure `empty?` works on symbols.
4
+
1
5
  # 1.0.2
2
6
 
3
7
  (troessner) Slightly improved handling of current states.
@@ -51,7 +51,7 @@ If this is not the case for you you have to add
51
51
 
52
52
  whereever you load your dependencies in your application.
53
53
 
54
- <b>Know limitations:</b>
54
+ <b>Known limitations:</b>
55
55
 
56
56
  * You can only use one state machine per model. While in theory you can define two or more, this won't work as you would expect. Not supporting this was intentional, if you're interested in the ratione look up version 1.0.0 in the CHANGELOG.
57
57
 
@@ -59,6 +59,15 @@ whereever you load your dependencies in your application.
59
59
 
60
60
  === Features
61
61
 
62
+ ==== Getting and setting the current state
63
+
64
+ Use the (surprise ahead) `current_state` method - in case you didn't set a state explicitly you'll get back the state that you defined as initial state.
65
+
66
+ >> Product.new.current_state
67
+ => :available
68
+
69
+ You can also set a new state explicitly via `update_current_state(new_state, persist = true / false)` but you should never do this unless you really know what you're doing and why - rather use events / state transitions (see below).
70
+
62
71
  ==== Events
63
72
 
64
73
  When you declare an event, say <tt>discontinue</tt>, three methods are declared for
@@ -79,7 +79,7 @@ module Transitions
79
79
  value = instance_variable_set(ivar, read_state)
80
80
  end
81
81
 
82
- !(value.nil? || value.empty?) ? value : sm.initial_state
82
+ !(value.nil? || value.to_s.empty?) ? value : sm.initial_state
83
83
  end
84
84
 
85
85
  def self.active_record_descendant?(klazz)
@@ -1,3 +1,3 @@
1
1
  module Transitions
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transitions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-08 00:00:00.000000000 Z
13
+ date: 2012-10-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -179,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: -696557581
182
+ hash: -465074797
183
183
  required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  none: false
185
185
  requirements: