stately 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad6d6e8f058bd9a7bb43c5860dcf3be61a0dc1b3
4
- data.tar.gz: 5464d5e302cb6719f314c52c57d84cb55d86d504
3
+ metadata.gz: 5a53df7047916b347c3064c06dffd6a23c683efa
4
+ data.tar.gz: 5f49e5f0ee667963bb48c9910fdb3da756b5b9a1
5
5
  SHA512:
6
- metadata.gz: 7b573a8920bbcc8de47f7a558a215c280f1c2f8f45d92d5b07ae7736a5cb0f5161790bdee90a6631b1ac91e82be83064b85e1b73d01c691eccdb4aa1b5d68db1
7
- data.tar.gz: f8c318f5095e66d2431cc33eb407c0c278fb405afe06c5abc431476d89fae02207e2d9c0e905d89dbf290922c1cf128adfbcc7d76e97f99d56e96677e1e6e460
6
+ metadata.gz: 6b6cbf227d0c8db10d54d5478ec6de0d648b33c4107a789ee225dc3de4081034b66c91baf8fa7212419965a00c051675e25b64abd66c83830283ba29f0c71305
7
+ data.tar.gz: e9efc6b438cda558b33657235fcb80b986671ae5c6687172e192c29998b9ab40d2d13a270c8494404788320b69f90370a8db525a4b58873584e0f9f3f92ff40d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stately (0.3.2)
4
+ stately (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/stately.rb CHANGED
@@ -53,20 +53,20 @@ module Stately
53
53
  options = opts.last.is_a?(Hash) ? opts.last : {}
54
54
  options[:attr] ||= :state
55
55
 
56
- self.stately_machine = Stately::Machine.new(options[:attr], options[:start])
57
- self.stately_machine.instance_eval(&block) if block_given?
56
+ @stately_machine = Stately::Machine.new(options[:attr], options[:start])
57
+ @stately_machine.instance_eval(&block) if block_given?
58
58
 
59
59
  include Stately::InstanceMethods
60
60
  end
61
61
 
62
62
  # Get the current Stately::Machine object
63
63
  def stately_machine
64
- @@stately_machine
64
+ self.instance_variable_get(:@stately_machine)
65
65
  end
66
66
 
67
67
  # Set the current Stately::Machine object
68
68
  def stately_machine=(obj)
69
- @@stately_machine = obj
69
+ @stately_machine = obj
70
70
  end
71
71
  end
72
72
 
@@ -108,6 +108,10 @@ module Stately
108
108
 
109
109
  private
110
110
 
111
+ def stately_machine
112
+ self.class.stately_machine
113
+ end
114
+
111
115
  def allowed_state_transition?(to_state)
112
116
  if current_state == to_state.to_s
113
117
  raise InvalidTransition,
@@ -1,3 +1,3 @@
1
1
  module Stately
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -0,0 +1,33 @@
1
+ require 'ostruct'
2
+ require 'spec_helper'
3
+
4
+ describe "two objects" do
5
+ class1 = Class.new(OpenStruct) do
6
+ stately :start => :object1_started, :attr => :object1_state do
7
+ state :object1_processed, :action => :processed do
8
+ allow_from :object1_started
9
+ end
10
+ end
11
+ end
12
+
13
+ class2 = Class.new(OpenStruct) do
14
+ stately :start => :object2_started, :attr => :object2_state do
15
+ state :object2_processed, :action => :processed do
16
+ allow_from :object2_started
17
+ end
18
+ end
19
+ end
20
+
21
+ context "should have individual state" do
22
+ let!(:object1) { class1.new }
23
+ let!(:object2) { class2.new }
24
+
25
+ it "object1 should get the value of object1_state" do
26
+ object1.respond_to?(:object1_state).should be_true
27
+ end
28
+
29
+ it "object2 should get the value of object2_state" do
30
+ object2.respond_to?(:object2_state).should be_true
31
+ end
32
+ end
33
+ end
@@ -16,8 +16,8 @@ describe Stately::InstanceMethods do
16
16
 
17
17
  describe 'initialize' do
18
18
  it 'creates a new Stately::Machine' do
19
- @object.stately_machine.class.should == Stately::Machine
20
- @object.stately_machine.should == @test_class.stately_machine
19
+ @object.class.stately_machine.class.should == Stately::Machine
20
+ @object.class.stately_machine.should == @test_class.stately_machine
21
21
  end
22
22
 
23
23
  it 'sets initial state' do
@@ -49,11 +49,11 @@ describe Stately::InstanceMethods do
49
49
  end
50
50
 
51
51
  it 'defines an instance-level accessor called stately_machine' do
52
- @test_class.method_defined?(:stately_machine).should be_true
52
+ @test_class.class.method_defined?(:stately_machine).should be_true
53
53
  end
54
54
 
55
55
  it 'defines a class-level setter called stately_machine=' do
56
- @test_class.respond_to?(:stately_machine=).should be_true
56
+ @test_class.class.respond_to?(:stately_machine=).should be_true
57
57
  end
58
58
 
59
59
  it 'defines an instance-level setter called stately_machine=' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stately
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Twomey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-27 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -103,6 +103,7 @@ files:
103
103
  - lib/stately/version.rb
104
104
  - lib/tasks/stately_tasks.rake
105
105
  - spec/functional/stately_spec.rb
106
+ - spec/functional/two_objets_spec.rb
106
107
  - spec/spec_helper.rb
107
108
  - spec/unit/stately/machine_spec.rb
108
109
  - spec/unit/stately/state_spec.rb