Sha256: a98f8188fd2eaf3a112374f79ec116369a423624a1e20417c25f0808275c663c

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 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, category: nil, url_options: {})
    short_url = Shortener::ShortenedUrl.generate(
      url,
      owner:      owner,
      custom_key: custom_key,
      expires_at: expires_at,
      fresh:      fresh,
      category:   category
    )

    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.7.1 app/helpers/shortener/shortener_helper.rb
shortener-0.6.2 app/helpers/shortener/shortener_helper.rb