This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
# if key doesn't exist, returns false | |
# if self[key] == false, returns false | |
# if self[key] == nil, empty, or blank, returns false | |
# if self[key] exists and self[key] == true, or evaluates to true, returns true | |
def has_key_and_value? (key) | |
return false unless has_key?(key) | |
return false if self[key].nil? | |
return false if self[key].respond_to?(:empty?) && self[key].empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Current key is always the most current version of the document. Everytime it gets modified, we increase the count of versions and save current couchbase version of document #as a version with current_version - 1 appended. | |
#So: | |
#create_doc | |
#mydoc = { "txt" => "my first text" } | |
#replace_doc | |
#mydoc::version = 2 | |
#mydoc::version::1 = { "txt" => "my_first_text", "auto_version" => 1, "auto_version_stamp" => "6/28/2012 20:35" } |