minimal_state_machine 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -59,9 +59,9 @@ What would happen with this configuration:
59
59
  Issue.new.state
60
60
  => #<IssueState::Open id: nil, type: "IssueState::Open", state_machine_id: nil, state_machine_type: "Issue", created_at: nil, updated_at: nil>
61
61
 
62
- issue = Issue.new
63
- issue.save
62
+ issue = Issue.create
64
63
  issue.state_name = 'closed'
64
+ issue.save
65
65
  issue.state
66
66
  => #<IssueState::Closed id: 1, type: "IssueState::Closed", state_machine_id: 1, state_machine_type: "Issue", created_at: "2013-01-03 19:13:31", updated_at: "2013-01-03 19:13:31">
67
67
  ```
@@ -1,3 +1,3 @@
1
1
  module MinimalStateMachine
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -29,6 +29,10 @@ module MinimalStateMachine
29
29
  end
30
30
  end
31
31
 
32
+ def state_name
33
+ self.class.states.invert[state.class].to_s
34
+ end
35
+
32
36
  private
33
37
 
34
38
  class InvalidTransitionError < StandardError; end
@@ -52,6 +52,10 @@ describe StateMachine do
52
52
  @state_machine.state.should be_a(StateMachineClosed)
53
53
  end
54
54
 
55
+ it 'provides a human friendly getter for the state_name' do
56
+ @state_machine.state_name.should == 'open'
57
+ end
58
+
55
59
  it 'destroys the previous state after the transition' do
56
60
  @state_machine.state_name = 'closed'
57
61
  @state_machine.save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal_state_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-03 00:00:00.000000000 Z
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord