def add(url, code = nil, options = nil)
      sha     = url_key url
      url_obj = @url_bucket.get_or_new sha, :r => 1
      if url_obj.raw_data
        fix_url_object(url_obj)
        code = url_obj.data
      end

      code = get_code(url, code, options)
      code_obj = @code_bucket.get_or_new code
      code_obj.content_type = url_obj.content_type = PLAIN

      if existing_url = code_obj.data # key exists
        raise DuplicateCodeError.new(existing_url, url, code) if url_key(existing_url) != sha
      end

      if !url_obj.data # unsaved
        url_obj.data = code
        url_obj.store
      end

      code_obj.data = url
      code_obj.store
      code
    end
def add(url, code = nil, options = nil)
      sha     = url_key url
      url_obj = @url_bucket.get_or_new sha, :r => 1
      if url_obj.raw_data
        fix_url_object(url_obj)
        code = url_obj.data
      end

      code = get_code(url, code, options)
      code_obj = @code_bucket.get_or_new code
      code_obj.content_type = url_obj.content_type = PLAIN

      if existing_url = code_obj.data # key exists
        raise DuplicateCodeError.new(existing_url, url, code) if url_key(existing_url) != sha
      end

      if !url_obj.data # unsaved
        url_obj.data = code
        url_obj.store
      end

      code_obj.data = url
      code_obj.store
      code
    end
Initializes the adapter.

 code_bucket - The Riak::Bucket for all code keys.
 url_bucket  - The Riak::Bucket for all url keys.  If this is not
               given, the code bucket is used for all keys.
 Public: Stores the shortened version of a URL.

 url     - The String URL to shorten and store.
 code    - Optional String code for the URL.
 options - Optional Guillotine::Service::Options

 Returns the unique String code for the URL.  If the URL is added
 multiple times, this should return the same code.