couchbase / couchbase-ruby-model

The Active Model implementation for Couchbase Server built on couchbase-ruby-client
61 stars 23 forks source link

Support ActiveRecord callbacks #18

Open alexanderedge opened 11 years ago

alexanderedge commented 11 years ago

Couchrest-model supports the following callbacks:

:before_validation, :after_validation, :after_initialize, :before_create, :around_create, :after_create, :before_destroy, :around_destroy, :after_destroy, :before_save, :around_save, :after_save, :before_update, :around_update, :after_update

However, couchbase-ruby-model doesn't seem to support them all since I am receiving the following error:

undefined method 'before_validation' for User(id):Class (NoMethodError)

Would it be possible to add the missing callbacks?

stakach commented 10 years ago

Easy enough to do manually:

define_model_callbacks :save, :create before_save :func before_create :func

mje113 commented 10 years ago

All the remaining callbacks were added here: https://github.com/couchbase/couchbase-ruby-model/commit/631e3d1f490fd8b39ad011cfb3a5ab1fbd19c39a So they're available in master--waiting on a new version for them to make it into the gem release.