aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/base.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-02-19 21:20:15 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-02-19 21:20:15 +0100
commitd8f1ee4b41352b870f617b01099b2877f754d32c (patch)
treedd6bdf1d1ded6aab7bb926109a24e942fc740b73 /activeresource/lib/active_resource/base.rb
parent8ba1fc18e13c03966d411947180022c1730e81ff (diff)
parent7c0e008973e594ebf53607362c1dfbe34b693600 (diff)
downloadrails-d8f1ee4b41352b870f617b01099b2877f754d32c.tar.gz
rails-d8f1ee4b41352b870f617b01099b2877f754d32c.tar.bz2
rails-d8f1ee4b41352b870f617b01099b2877f754d32c.zip
Merge commit 'mainstream/master'
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r--activeresource/lib/active_resource/base.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 94418fb559..a8c0da31f2 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -462,7 +462,7 @@ module ActiveResource
# that_guy.valid? # => false
# that_guy.new? # => true
def create(attributes = {})
- returning(self.new(attributes)) { |res| res.save }
+ self.new(attributes).tap { |resource| resource.save }
end
# Core method for finding resources. Used similarly to Active Record's +find+ method.
@@ -600,7 +600,7 @@ module ActiveResource
end
def instantiate_record(record, prefix_options = {})
- returning new(record) do |resource|
+ new(record).tap do |resource|
resource.prefix_options = prefix_options
end
end
@@ -747,7 +747,7 @@ module ActiveResource
#
def ==(other)
other.equal?(self) || (other.instance_of?(self.class) && other.id == id && other.prefix_options == prefix_options)
- end
+ end
# Tests for equality (delegates to ==).
def eql?(other)
@@ -773,7 +773,7 @@ module ActiveResource
# my_invoice.customer # => That Company
# next_invoice.customer # => That Company
def dup
- returning self.class.new do |resource|
+ self.class.new.tap do |resource|
resource.attributes = @attributes
resource.prefix_options = @prefix_options
end
@@ -985,14 +985,14 @@ module ActiveResource
# Update the resource on the remote service.
def update
- returning connection.put(element_path(prefix_options), encode, self.class.headers) do |response|
+ connection.put(element_path(prefix_options), encode, self.class.headers).tap do |response|
load_attributes_from_response(response)
end
end
# Create (i.e., \save to the remote service) the \new resource.
def create
- returning connection.post(collection_path, encode, self.class.headers) do |response|
+ connection.post(collection_path, encode, self.class.headers).tap do |response|
self.id = id_from_response(response)
load_attributes_from_response(response)
end