Sha256: cdef1ec7216a68d0186f97ff3238302cf5d9886ec9229a7529ed1d6c59dd2a3c

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

module Shortener::ShortenerHelper

  # generate a url from a url string
  def short_url(url, owner: nil, custom_key: nil, expires_at: nil, fresh: false, url_options: {})
    short_url = Shortener::ShortenedUrl.generate(url,
                                                  owner:      owner,
                                                  custom_key: custom_key,
                                                  expires_at: expires_at,
                                                  fresh:      fresh
                                                )

    if short_url
      options = { controller: :"shortener/shortened_urls", action: :show, id: short_url.unique_key, only_path: false }.merge(url_options)
      url_for(options)
    else
      url
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shortener-0.5.5 app/helpers/shortener/shortener_helper.rb
shortener-0.5.4 app/helpers/shortener/shortener_helper.rb