Skip to content
This repository
Browse code

Setup ActiveResource autoloads

  • Loading branch information...
commit 0b694a4ff41dbb7f64b6ea4cb088c2c2ba26b569 1 parent 28f3627
Joshua Peek josh authored
1  activeresource/examples/simple.rb
... ... @@ -1,6 +1,5 @@
1 1 $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2 2 require 'active_resource'
3   -require 'active_resource/http_mock'
4 3 require 'active_support/core_ext/hash/conversions'
5 4
6 5 ActiveSupport::XmlMini.backend = ENV['XMLMINI'] || 'REXML'
19 activeresource/lib/active_resource.rb
@@ -25,18 +25,15 @@
25 25 $:.unshift(activesupport_path) if File.directory?(activesupport_path)
26 26 require 'active_support'
27 27
28   -begin
29   - require 'active_model'
30   -rescue LoadError
31   - $:.unshift "#{File.dirname(__FILE__)}/../../activemodel/lib"
32   - require 'active_model'
33   -end
34   -
35   -require 'active_resource/formats'
36   -require 'active_resource/base'
37   -require 'active_resource/validations'
38   -require 'active_resource/custom_methods'
  28 +activemodel_path = "#{File.dirname(__FILE__)}/../../activemodel/lib"
  29 +$:.unshift(activemodel_path) if File.directory?(activemodel_path)
  30 +require 'active_model'
39 31
40 32 module ActiveResource
41 33 autoload :Base, 'active_resource/base'
  34 + autoload :Connection, 'active_resource/connection'
  35 + autoload :CustomMethods, 'active_resource/custom_methods'
  36 + autoload :Formats, 'active_resource/formats'
  37 + autoload :Validations, 'active_resource/validations'
  38 + autoload :HttpMock, 'active_resource/http_mock'
42 39 end
12 activeresource/lib/active_resource/base.rb
@@ -10,10 +10,9 @@
10 10 require 'set'
11 11 require 'uri'
12 12
13   -module ActiveResource
14   - autoload :Formats, 'active_resource/formats'
15   - autoload :Connection, 'active_resource/connection'
  13 +require 'active_resource/exceptions'
16 14
  15 +module ActiveResource
17 16 # ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application.
18 17 #
19 18 # 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:
1085 1084 end
1086 1085 end
1087 1086 end
1088   -end
1089 1087
1090   -require 'active_resource/validations'
1091   -require 'active_resource/custom_methods'
  1088 + class Base
  1089 + include CustomMethods, Validations
  1090 + end
  1091 +end
2  activeresource/lib/active_resource/connection.rb
... ... @@ -1,5 +1,3 @@
1   -require 'active_resource/exceptions'
2   -require 'active_resource/formats'
3 1 require 'active_support/core_ext/benchmark'
4 2 require 'net/https'
5 3 require 'date'
4 activeresource/lib/active_resource/custom_methods.rb
@@ -117,8 +117,4 @@ def custom_method_new_element_url(method_name, options = {})
117 117 end
118 118 end
119 119 end
120   -
121   - class Base
122   - include CustomMethods
123   - end
124 120 end
1  activeresource/lib/active_resource/http_mock.rb
... ... @@ -1,4 +1,3 @@
1   -require 'active_resource/connection'
2 1 require 'active_support/core_ext/kernel/reporting'
3 2
4 3 module ActiveResource
5 activeresource/lib/active_resource/validations.rb
... ... @@ -1,4 +1,3 @@
1   -require 'active_resource/exceptions'
2 1 require 'active_support/core_ext/array/wrap'
3 2
4 3 module ActiveResource
@@ -80,8 +79,4 @@ def errors
80 79 @errors ||= Errors.new(self)
81 80 end
82 81 end
83   -
84   - class Base
85   - include Validations
86   - end
87 82 end
1  activeresource/test/abstract_unit.rb
@@ -6,7 +6,6 @@
6 6
7 7 $:.unshift "#{File.dirname(__FILE__)}/../lib"
8 8 require 'active_resource'
9   -require 'active_resource/http_mock'
10 9
11 10 $:.unshift "#{File.dirname(__FILE__)}/../test"
12 11 require 'setter_trap'

0 comments on commit 0b694a4

Please sign in to comment.
Something went wrong with that request. Please try again.