lib/guillotine/adapters/sequel_adapter.rb
# 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.
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.
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 .
def add(url, code = nil, options = nil)
      if existing = code_for(url)
        existing
      else
        code = get_code(url, code, options)
        begin
          @table << {:url => url, :code => code}
        rescue Sequel::DatabaseError
          if existing_url = @table.select(:url).where(:code => code).first
            raise DuplicateCodeError.new(existing_url, url, code)
          else
            raise
          end
        end
        code
      end
    end
def add ( url , code = nil , options = nil ) if existing = code_for ( url ) existing else code = get_code ( url , code , options ) begin @table << { :url => url , :code => code } rescue Sequel :: DatabaseError if existing_url = @table . select ( :url ) . where ( :code => code ) . first raise DuplicateCodeError . new ( existing_url , url , code ) else raise end end code end end
Public: Stores the shortened version of a URL.
Public : Stores the shortened version of a URL .
url
<not_specific>
code
<not_specific>
options
<not_specific>