Skip to content
Browse files

Add before/after create callbacks

add before_create/after_create callbacks.
Warning: Not well tested!
  • Loading branch information...
1 parent 7ab4c94 commit 0dfae96b550f077c28ad51f1420628af1ba66500 taryneast committed Jan 14, 2010
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/hyperactive_resource.rb
View
2 lib/hyperactive_resource.rb
@@ -549,11 +549,13 @@ def update
# Create (i.e. save to the remote service) the new resource.
def create
return false unless self.valid?
+ run_callbacks(:before_create)
connection.post(collection_path, encode, self.class.headers).tap do |response|
save_nested
load_attributes_from_response(response)
merge_saved_nested_resources_into_attributes
end
+ run_callbacks(:after_create)
self
end

0 comments on commit 0dfae96

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