aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activeresource/lib')
-rw-r--r--activeresource/lib/active_resource/observing.rb13
-rw-r--r--activeresource/lib/active_resource/validations.rb4
-rw-r--r--activeresource/lib/activeresource.rb1
3 files changed, 14 insertions, 4 deletions
diff --git a/activeresource/lib/active_resource/observing.rb b/activeresource/lib/active_resource/observing.rb
index 94836f4bb1..3c74d49c80 100644
--- a/activeresource/lib/active_resource/observing.rb
+++ b/activeresource/lib/active_resource/observing.rb
@@ -4,7 +4,18 @@ module ActiveResource
include ActiveModel::Observing
included do
- wrap_with_notifications :create, :save, :update, :destroy
+ %w( create save update destroy ).each do |method|
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{method}_with_notifications(*args, &block)
+ notify_observers(:before_#{method})
+ if result = #{method}_without_notifications(*args, &block)
+ notify_observers(:after_#{method})
+ end
+ result
+ end
+ EOS
+ alias_method_chain(method, :notifications)
+ end
end
end
end
diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb
index d4d282e273..67b69fa505 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -93,9 +93,9 @@ module ActiveResource
# content-type of the error-block received
def load_remote_errors(remote_errors, save_cache = false ) #:nodoc:
case remote_errors.response['Content-Type']
- when 'application/xml'
+ when /xml/
errors.from_xml(remote_errors.response.body, save_cache)
- when 'application/json'
+ when /json/
errors.from_json(remote_errors.response.body, save_cache)
end
end
diff --git a/activeresource/lib/activeresource.rb b/activeresource/lib/activeresource.rb
deleted file mode 100644
index e076455b16..0000000000
--- a/activeresource/lib/activeresource.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'active_resource'