aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r--activeresource/lib/active_resource/base.rb23
1 files changed, 9 insertions, 14 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 11a7bbba3e..a4f2a7e16a 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -10,10 +10,9 @@ require 'active_support/core_ext/object/misc'
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.
@@ -873,7 +872,7 @@ module ActiveResource
attributes.to_xml({:root => self.class.element_name}.merge(options))
end
- # Converts the resource to a JSON string representation.
+ # Coerces to a hash for JSON encoding.
#
# ==== Options
# The +options+ are passed to the +to_json+ method on each
@@ -897,8 +896,8 @@ module ActiveResource
#
# person.to_json(:except => ["first_name"])
# # => {"last_name": "Smith"}
- def to_json(options={})
- ActiveSupport::JSON.encode(attributes, options)
+ def as_json(options = nil)
+ attributes.as_json(options)
end
# Returns the serialized string representation of the resource in the configured
@@ -1072,11 +1071,6 @@ module ActiveResource
self.class.__send__(:split_options, options)
end
- # For compatibility with ActiveSupport::JSON.encode
- def rails_to_json(options, *args)
- to_json(options)
- end
-
def method_missing(method_symbol, *arguments) #:nodoc:
method_name = method_symbol.to_s
@@ -1090,7 +1084,8 @@ module ActiveResource
end
end
end
-end
-require 'active_resource/validations'
-require 'active_resource/custom_methods'
+ class Base
+ include CustomMethods, Validations
+ end
+end