Created
June 4, 2013 00:44
-
-
Save mattsnyder/5702743 to your computer and use it in GitHub Desktop.
Set a custom key on a Ripple document for Riak
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
include Ripple::Document | |
property :custom_key, String | |
key_on :custom_key | |
before_save :set_key | |
def set_key | |
self[:custom_key] ||= "#{self.created_at.utc.to_s(:key)}-#{SecureRandom.hex(8)}" | |
self[:custom_key] | |
end | |
private :set_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment