transitions 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -6,9 +6,30 @@ commit}[http://github.com/rails/rails/commit/db49c706b62e7ea2ab93f05399dbfddf508
6
6
 
7
7
  == Installation
8
8
 
9
- Just paste the following line into the Gemfile:
9
+ If you're using Rails + ActiveRecord + Bundler
10
10
 
11
- gem "transitions"
11
+ # in your Gemfile
12
+ gem "transitions", :require => ["transitions", "active_record/transitions"]
13
+
14
+ # in your AR models that will use the state machine
15
+ include ::Transitions
16
+ include ActiveRecord::Transitions
17
+
18
+ state_machine do
19
+ state :available # first one is initial state
20
+ state :out_of_stock
21
+ state :discontinue
22
+
23
+ event :discontinue do
24
+ transitions :to => :discontinue, :from => [:available, :out_of_stock], :on_transition => :do_discontinue
25
+ end
26
+ event :out_of_stock do
27
+ transitions :to => :out_of_stock, :from => [:available, :discontinue]
28
+ end
29
+ event :available do
30
+ transitions :to => :available, :from => [:out_of_stock], :on_transition => :send_alerts
31
+ end
32
+ end
12
33
 
13
34
  == Copyright
14
35
 
@@ -33,7 +33,7 @@ module ActiveRecord
33
33
  protected
34
34
 
35
35
  def write_state(state_machine, state)
36
- update_attributes! :state => state.to_s
36
+ update_attribute(:state, state.to_s)
37
37
  end
38
38
 
39
39
  def read_state(state_machine)
data/lib/transitions.rb CHANGED
@@ -24,10 +24,9 @@ require "transitions/event"
24
24
  require "transitions/machine"
25
25
  require "transitions/state"
26
26
  require "transitions/state_transition"
27
+ require "transitions/version"
27
28
 
28
29
  module Transitions
29
- VERSION = "0.0.6"
30
-
31
30
  class InvalidTransition < Exception
32
31
 
33
32
  end
@@ -0,0 +1,3 @@
1
+ module Transitions
2
+ VERSION = "0.0.7"
3
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transitions
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 6
9
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Jakub Ku\xC5\xBAma"
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-20 00:00:00 +02:00
18
+ date: 2010-06-29 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: test-unit
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 2
29
32
  - 0
@@ -34,9 +37,11 @@ dependencies:
34
37
  name: mocha
35
38
  prerelease: false
36
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
37
41
  requirements:
38
42
  - - ">="
39
43
  - !ruby/object:Gem::Version
44
+ hash: 3
40
45
  segments:
41
46
  - 0
42
47
  version: "0"
@@ -46,9 +51,11 @@ dependencies:
46
51
  name: sqlite3-ruby
47
52
  prerelease: false
48
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
49
55
  requirements:
50
56
  - - ">="
51
57
  - !ruby/object:Gem::Version
58
+ hash: 3
52
59
  segments:
53
60
  - 0
54
61
  version: "0"
@@ -58,9 +65,11 @@ dependencies:
58
65
  name: activerecord
59
66
  prerelease: false
60
67
  requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
61
69
  requirements:
62
70
  - - ">="
63
71
  - !ruby/object:Gem::Version
72
+ hash: 3
64
73
  segments:
65
74
  - 0
66
75
  version: "0"
@@ -75,11 +84,12 @@ extensions: []
75
84
  extra_rdoc_files: []
76
85
 
77
86
  files:
87
+ - lib/transitions.rb
88
+ - lib/transitions/state_transition.rb
78
89
  - lib/transitions/state.rb
79
- - lib/transitions/machine.rb
80
90
  - lib/transitions/event.rb
81
- - lib/transitions/state_transition.rb
82
- - lib/transitions.rb
91
+ - lib/transitions/version.rb
92
+ - lib/transitions/machine.rb
83
93
  - lib/active_record/transitions.rb
84
94
  - LICENSE
85
95
  - README.rdoc
@@ -93,16 +103,20 @@ rdoc_options: []
93
103
  require_paths:
94
104
  - lib
95
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
96
107
  requirements:
97
108
  - - ">="
98
109
  - !ruby/object:Gem::Version
110
+ hash: 3
99
111
  segments:
100
112
  - 0
101
113
  version: "0"
102
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
103
116
  requirements:
104
117
  - - ">="
105
118
  - !ruby/object:Gem::Version
119
+ hash: 23
106
120
  segments:
107
121
  - 1
108
122
  - 3
@@ -111,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
125
  requirements: []
112
126
 
113
127
  rubyforge_project:
114
- rubygems_version: 1.3.6
128
+ rubygems_version: 1.3.7
115
129
  signing_key:
116
130
  specification_version: 3
117
131
  summary: State machine extracted from ActiveModel