Skip to content

Commit

Permalink
use active_model to avoid using active_record namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
siuying committed Mar 20, 2012
1 parent 5e4b1c0 commit 0585087
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.rdoc
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions test/test_active_record.rb
Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +73,7 @@ class ConditionalValidatingTrafficLight < TrafficLight
end

class LightBulb < ActiveRecord::Base
include ActiveRecord::Transitions
include ActiveModel::Transitions

state_machine do
state :off
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/test_active_record_timestamps.rb
Expand Up @@ -4,7 +4,7 @@
create_database

class Order < ActiveRecord::Base
include ActiveRecord::Transitions
include ActiveModel::Transitions

state_machine do
state :opened
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0585087

Please sign in to comment.