Browse files

Setup ActiveResource autoloads

  • Loading branch information...
1 parent 28f3627 commit 0b694a4ff41dbb7f64b6ea4cb088c2c2ba26b569 @josh josh committed Jun 9, 2009
View
1 activeresource/examples/simple.rb
@@ -1,6 +1,5 @@
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'active_resource'
-require 'active_resource/http_mock'
require 'active_support/core_ext/hash/conversions'
ActiveSupport::XmlMini.backend = ENV['XMLMINI'] || 'REXML'
View
19 activeresource/lib/active_resource.rb
@@ -25,18 +25,15 @@
$:.unshift(activesupport_path) if File.directory?(activesupport_path)
require 'active_support'
-begin
- require 'active_model'
-rescue LoadError
- $:.unshift "#{File.dirname(__FILE__)}/../../activemodel/lib"
- require 'active_model'
-end
-
-require 'active_resource/formats'
-require 'active_resource/base'
-require 'active_resource/validations'
-require 'active_resource/custom_methods'
+activemodel_path = "#{File.dirname(__FILE__)}/../../activemodel/lib"
+$:.unshift(activemodel_path) if File.directory?(activemodel_path)
+require 'active_model'
module ActiveResource
autoload :Base, 'active_resource/base'
+ autoload :Connection, 'active_resource/connection'
+ autoload :CustomMethods, 'active_resource/custom_methods'
+ autoload :Formats, 'active_resource/formats'
+ autoload :Validations, 'active_resource/validations'
+ autoload :HttpMock, 'active_resource/http_mock'
end
View
12 activeresource/lib/active_resource/base.rb
@@ -10,10 +10,9 @@
require 'set'
require 'uri'
-module ActiveResource
- autoload :Formats, 'active_resource/formats'
- autoload :Connection, 'active_resource/connection'
+require 'active_resource/exceptions'
+module ActiveResource
# ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application.
#
# For an outline of what Active Resource is capable of, see link:files/vendor/rails/activeresource/README.html.
@@ -1085,7 +1084,8 @@ def method_missing(method_symbol, *arguments) #:nodoc:
end
end
end
-end
-require 'active_resource/validations'
-require 'active_resource/custom_methods'
+ class Base
+ include CustomMethods, Validations
+ end
+end
View
2 activeresource/lib/active_resource/connection.rb
@@ -1,5 +1,3 @@
-require 'active_resource/exceptions'
-require 'active_resource/formats'
require 'active_support/core_ext/benchmark'
require 'net/https'
require 'date'
View
4 activeresource/lib/active_resource/custom_methods.rb
@@ -117,8 +117,4 @@ def custom_method_new_element_url(method_name, options = {})
end
end
end
-
- class Base
- include CustomMethods
- end
end
View
1 activeresource/lib/active_resource/http_mock.rb
@@ -1,4 +1,3 @@
-require 'active_resource/connection'
require 'active_support/core_ext/kernel/reporting'
module ActiveResource
View
5 activeresource/lib/active_resource/validations.rb
@@ -1,4 +1,3 @@
-require 'active_resource/exceptions'
require 'active_support/core_ext/array/wrap'
module ActiveResource
@@ -80,8 +79,4 @@ def errors
@errors ||= Errors.new(self)
end
end
-
- class Base
- include Validations
- end
end
View
1 activeresource/test/abstract_unit.rb
@@ -6,7 +6,6 @@
$:.unshift "#{File.dirname(__FILE__)}/../lib"
require 'active_resource'
-require 'active_resource/http_mock'
$:.unshift "#{File.dirname(__FILE__)}/../test"
require 'setter_trap'

0 comments on commit 0b694a4

Please sign in to comment.