Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use active_model to avoid using active_record namespaces

  • Loading branch information...
commit 0585087723baa0ae25516bec4195c2c311c80d3e 1 parent 5e4b1c0
@siuying siuying authored
View
8 README.rdoc
@@ -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
View
2  lib/active_record/transitions.rb → lib/active_model/transitions.rb
@@ -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
2  test/helper.rb
@@ -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
View
6 test/test_active_record.rb
@@ -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
View
4 test/test_active_record_timestamps.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.