state_manager 0.2.13 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'byebug'
7
6
  gem "bundler"
8
7
  gem 'delayed_job_active_record'
9
8
  gem 'activerecord'
@@ -66,7 +66,7 @@ module StateManager
66
66
 
67
67
  module InstanceMethods
68
68
  def initialize(*args)
69
- super(*args)
69
+ super
70
70
  self.state_managers ||= {}
71
71
  end
72
72
 
@@ -143,5 +143,10 @@ module StateManager
143
143
 
144
144
  attr_writer :name, :states, :parent_state
145
145
 
146
+ def method_missing(name, *args, &block)
147
+ resource.send(name, *args, &block)
148
+ end
149
+
150
+
146
151
  end
147
152
  end
@@ -1,3 +1,3 @@
1
1
  module StateManager
2
- VERSION = "0.2.13"
2
+ VERSION = "0.3.0"
3
3
  end
data/test/basic_test.rb CHANGED
@@ -3,6 +3,9 @@ require 'helper'
3
3
  class BasicTest < Minitest::Test
4
4
 
5
5
  class PostStates < StateManager::Base
6
+
7
+ attr_accessor :title
8
+
6
9
  state :unsubmitted do
7
10
  event :submit, :transitions_to => 'submitted.awaiting_review'
8
11
  end
@@ -20,12 +23,22 @@ class BasicTest < Minitest::Test
20
23
  end
21
24
  state :active
22
25
  state :rejected
26
+
27
+ class Active
28
+ def entered
29
+ state_manager.title = title
30
+ end
31
+ end
32
+
23
33
  end
24
34
 
25
35
  class Post
36
+
26
37
  attr_accessor :state
27
38
  extend StateManager::Resource
28
39
  state_manager :state
40
+
41
+ attr_accessor :title
29
42
  end
30
43
 
31
44
  class PostWithInitialState
@@ -136,4 +149,11 @@ class BasicTest < Minitest::Test
136
149
  assert_state 'submitted.awaiting_review'
137
150
  end
138
151
 
152
+ def test_property_proxying
153
+ @resource = Post.new
154
+ @resource.title = 'some title'
155
+ @resource.state_manager.transition_to 'active'
156
+ assert_equal 'some title', @resource.state_manager.title
157
+ end
158
+
139
159
  end
data/test/helper.rb CHANGED
@@ -8,7 +8,6 @@ rescue Bundler::BundlerError => e
8
8
  exit e.status_code
9
9
  end
10
10
  require 'minitest/autorun'
11
- require 'byebug'
12
11
 
13
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: