Permalink
Browse files

use active_model to avoid using active_record namespaces

  • Loading branch information...
1 parent 5e4b1c0 commit 0585087723baa0ae25516bec4195c2c311c80d3e @siuying siuying committed Mar 20, 2012
View
@@ -12,11 +12,11 @@
This goes into your Gemfile:
- gem "transitions", :require => ["transitions", "active_record/transitions"]
+ gem "transitions", :require => ["transitions", "active_model/transitions"]
-… and this into your AR model:
+… and this into your ORM model:
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
== Standalone
@@ -62,7 +62,7 @@ bang(!)-version will call <tt>write_state</tt>.
Given a model like this:
class Order < ActiveRecord::Base
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
state_machine :auto_scopes => true do
state :pick_line_items
state :picking_line_items
@@ -20,7 +20,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-module ActiveRecord
+module ActiveModel
module Transitions
extend ActiveSupport::Concern
View
@@ -9,7 +9,7 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require "transitions"
-require "active_record/transitions"
+require "active_model/transitions"
class Test::Unit::TestCase
@@ -33,7 +33,7 @@ def self.up
CreateLights.migrate(:up)
class TrafficLight < ActiveRecord::Base
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
state_machine :auto_scopes => true do
state :off
@@ -73,7 +73,7 @@ class ConditionalValidatingTrafficLight < TrafficLight
end
class LightBulb < ActiveRecord::Base
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
state_machine do
state :off
@@ -203,7 +203,7 @@ class TestScopes < Test::Unit::TestCase
test 'scope generation raises an exception if we try to overwrite an existing method' do
assert_raise(Transitions::InvalidMethodOverride) {
class Light < ActiveRecord::Base
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
state_machine :auto_scopes => true do
state :new
@@ -4,7 +4,7 @@
create_database
class Order < ActiveRecord::Base
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
state_machine do
state :opened
@@ -104,7 +104,7 @@ def create_order(state = nil)
test "passing an invalid value to timestamp options should raise an exception" do
assert_raise(ArgumentError) do
class Order < ActiveRecord::Base
- include ActiveRecord::Transitions
+ include ActiveModel::Transitions
state_machine do
event :replace, timestamp: 1 do
transitions :from => :prepared, :to => :placed

0 comments on commit 0585087

Please sign in to comment.