sidestate 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENCE +1 -1
  2. data/README.textile +9 -1
  3. data/lib/sidestate/hook.rb +1 -1
  4. metadata +20 -41
data/LICENCE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Envato
1
+ Copyright (c) 2010 Envato & Pat Allan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.textile CHANGED
@@ -6,6 +6,8 @@ h2. Installation
6
6
 
7
7
  <pre><code>gem install sidestate</code></pre>
8
8
 
9
+ Don't forget to add it to your environment.rb or Gemfile.
10
+
9
11
  h2. Usage
10
12
 
11
13
  You'll want to set up AASM as normal, with states, events and transitions. To get SideState working nicely, you'll want to include the module of the same name into your model:
@@ -23,10 +25,16 @@ Then, you'll want the model and migration generated for the companion state obje
23
25
 
24
26
  You can add whatever you like to the new model (in this example, it would be called ArticleState), but make sure you don't delete the foreign key and name columns. It's also a good idea to add an index to the foreign key column (the generator isn't smart enough to do this yet).
25
27
 
28
+ *Important Note*: Sidestate adds a has_many association from the main class to the state class, and a belongs_to one in the other direction. You don't need to (and shouldn't) add these yourself.
29
+
30
+ *Another Important Note*: You will still need the state column (default is aasm_state) in your main class - this makes querying on the current state of objects much easier, and SideState expects it as well.
31
+
32
+ And that's pretty much it - whenever the state changes on your main class, a new state object will be saved to the database as well. Just keep using AASM as you normally do.
33
+
26
34
  h2. Warning
27
35
 
28
36
  Very much a beta, and might change dramatically. Seems to work in basic situations, at least. Your mileage may vary.
29
37
 
30
38
  h2. Credits
31
39
 
32
- Copyright (c) 2010 "Envato":http://envato.com/. Initially developed by "Pat Allan":http://freelancing-gods.com. Released under an open licence.
40
+ Copyright (c) 2010 "Envato":http://envato.com/. Initially developed by "Pat Allan":http://freelancing-gods.com. Released under an MIT licence.
@@ -44,7 +44,7 @@ module Sidestate::Hook
44
44
  return unless send("#{aasm_column}_changed?")
45
45
 
46
46
  old_state, new_state = send("#{aasm_column}_change")
47
- aasm_state_collection.create :name => new_state.to_s
47
+ aasm_state_collection.create :name => new_state.to_s, self.class.name.underscore.to_sym => self
48
48
  end
49
49
 
50
50
  def aasm_state_collection
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidestate
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
4
+ version: 0.2.1
10
5
  platform: ruby
11
6
  authors:
12
7
  - Pat Allan
@@ -19,58 +14,44 @@ default_executable:
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: aasm
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 2
29
- - 1
30
- - 5
31
23
  version: 2.1.5
32
- type: :runtime
33
- version_requirements: *id001
24
+ version:
34
25
  - !ruby/object:Gem::Dependency
35
26
  name: rspec
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
38
30
  requirements:
39
31
  - - ">="
40
32
  - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 2
44
- - 9
45
33
  version: 1.2.9
46
- type: :development
47
- version_requirements: *id002
34
+ version:
48
35
  - !ruby/object:Gem::Dependency
49
36
  name: yard
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
52
40
  requirements:
53
41
  - - ">="
54
42
  - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
43
  version: "0"
58
- type: :development
59
- version_requirements: *id003
44
+ version:
60
45
  - !ruby/object:Gem::Dependency
61
46
  name: timecop
62
- prerelease: false
63
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
64
50
  requirements:
65
51
  - - ">="
66
52
  - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- - 3
70
- - 4
71
53
  version: 0.3.4
72
- type: :development
73
- version_requirements: *id004
54
+ version:
74
55
  description: Track state history using AASM
75
56
  email: pat@freelancing-gods.com
76
57
  executables: []
@@ -98,20 +79,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
79
  requirements:
99
80
  - - ">="
100
81
  - !ruby/object:Gem::Version
101
- segments:
102
- - 0
103
82
  version: "0"
83
+ version:
104
84
  required_rubygems_version: !ruby/object:Gem::Requirement
105
85
  requirements:
106
86
  - - ">="
107
87
  - !ruby/object:Gem::Version
108
- segments:
109
- - 0
110
88
  version: "0"
89
+ version:
111
90
  requirements: []
112
91
 
113
92
  rubyforge_project:
114
- rubygems_version: 1.3.6
93
+ rubygems_version: 1.3.5
115
94
  signing_key:
116
95
  specification_version: 3
117
96
  summary: AASM Extention for storing state in a separate model