couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couch commit: updated refs/heads/2511-add-is-old-record to dd83465
Date Fri, 12 Dec 2014 20:27:44 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/2511-add-is-old-record [created] dd83465ce


Add IS_OLD_RECORD macro

This can be used in guards to detect if a state variable needs to be
upgraded. An example of it's use might be:

    handle_call(Msg, From, St) when ?IS_OLD_RECORD(St, #st{}) ->
        handle_call(Msg, From, upgrade_state(St));

This is useful for upgrading any of our various gen behaviors that
aren't properly supervised.

COUCHDB-2511


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/dd83465c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/dd83465c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/dd83465c

Branch: refs/heads/2511-add-is-old-record
Commit: dd83465cee262162bee4819dc21cbca073181861
Parents: a4dbd64
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Fri Dec 12 14:25:38 2014 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Fri Dec 12 14:25:38 2014 -0600

----------------------------------------------------------------------
 include/couch_db.hrl | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/dd83465c/include/couch_db.hrl
----------------------------------------------------------------------
diff --git a/include/couch_db.hrl b/include/couch_db.hrl
index df393e3..2b77d53 100644
--- a/include/couch_db.hrl
+++ b/include/couch_db.hrl
@@ -23,6 +23,8 @@
 -define(JSON_ENCODE(V), couch_util:json_encode(V)).
 -define(JSON_DECODE(V), couch_util:json_decode(V)).
 
+-define(IS_OLD_RECORD(V, R), (tuple_size(V) /= tuple_size(R))).
+
 -define(b2l(V), binary_to_list(V)).
 -define(l2b(V), list_to_binary(V)).
 -define(i2b(V), couch_util:integer_to_boolean(V)).


Mime
View raw message