couchrest_model/lib/couchrest/model/callbacks.rb

29 lines
483 B
Ruby
Raw Normal View History

# encoding: utf-8
module CouchRest #:nodoc:
module Model #:nodoc:
module Callbacks
extend ActiveSupport::Concern
included do
extend ActiveModel::Callbacks
define_model_callbacks \
:create,
:destroy,
:save,
:update
end
def valid?(context = nil)
context ||= (new_record? ? :create : :update)
output = super(context)
errors.empty? && output
end
end
end
end