aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-15 21:05:03 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-15 21:05:03 -0800
commit29a31912fcedde9e271af8a20b890f8c62e1ea79 (patch)
tree8c1d72fa399d7f60e22eef9e63a87dec2494df25 /activemodel/lib
parentd7bad6e2eba5b5ea0d83a4a2a4390b057c39ec7a (diff)
downloadrails-29a31912fcedde9e271af8a20b890f8c62e1ea79.tar.gz
rails-29a31912fcedde9e271af8a20b890f8c62e1ea79.tar.bz2
rails-29a31912fcedde9e271af8a20b890f8c62e1ea79.zip
Lazy-require state machine internals when the module is included
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/state_machine.rb8
-rw-r--r--activemodel/lib/active_model/state_machine/event.rb2
-rw-r--r--activemodel/lib/active_model/state_machine/machine.rb5
3 files changed, 8 insertions, 7 deletions
diff --git a/activemodel/lib/active_model/state_machine.rb b/activemodel/lib/active_model/state_machine.rb
index 96df6539ae..89afc4abb6 100644
--- a/activemodel/lib/active_model/state_machine.rb
+++ b/activemodel/lib/active_model/state_machine.rb
@@ -1,14 +1,10 @@
-Dir[File.dirname(__FILE__) + "/state_machine/*.rb"].sort.each do |path|
- filename = File.basename(path)
- require "active_model/state_machine/#{filename}"
-end
-
module ActiveModel
module StateMachine
class InvalidTransition < Exception
end
def self.included(base)
+ require 'active_model/state_machine/machine'
base.extend ClassMethods
end
@@ -63,4 +59,4 @@ module ActiveModel
end
end
end
-end \ No newline at end of file
+end
diff --git a/activemodel/lib/active_model/state_machine/event.rb b/activemodel/lib/active_model/state_machine/event.rb
index 8acde7fd47..3eb656b6d6 100644
--- a/activemodel/lib/active_model/state_machine/event.rb
+++ b/activemodel/lib/active_model/state_machine/event.rb
@@ -1,3 +1,5 @@
+require 'active_model/state_machine/state_transition'
+
module ActiveModel
module StateMachine
class Event
diff --git a/activemodel/lib/active_model/state_machine/machine.rb b/activemodel/lib/active_model/state_machine/machine.rb
index 170505c0b2..58c2f1b200 100644
--- a/activemodel/lib/active_model/state_machine/machine.rb
+++ b/activemodel/lib/active_model/state_machine/machine.rb
@@ -1,3 +1,6 @@
+require 'active_model/state_machine/state'
+require 'active_model/state_machine/event'
+
module ActiveModel
module StateMachine
class Machine
@@ -71,4 +74,4 @@ module ActiveModel
end
end
end
-end \ No newline at end of file
+end