Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created June 4, 2013 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsnyder/5702743 to your computer and use it in GitHub Desktop.
Save mattsnyder/5702743 to your computer and use it in GitHub Desktop.
Set a custom key on a Ripple document for Riak
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