module Funneler

Constants

Error
InvalidTokenError
UnknownFunnelType
VERSION

Attributes

configuration[R]

Public Class Methods

build(route_generator:, params: {}, expires_in_days: nil, meta: {}) click to toggle source
# File lib/funneler.rb, line 33
def build(route_generator:, params: {}, expires_in_days: nil, meta: {})
  Funneler::FunnelFactory.build(route_generator: route_generator,
                               params: params,
                               meta: meta,
                               expires_in_days: expires_in_days)
end
configure() { |configuration| ... } click to toggle source
# File lib/funneler.rb, line 22
def configure
  yield(configuration)
end
from_routes(routes: {}, meta: {}) click to toggle source
# File lib/funneler.rb, line 40
def from_routes(routes: {}, meta: {})
  Funnel.new('routes' => routes,
             'current_page_index' => 0,
             'meta' => meta)
end
from_token(token:, current_page_index: nil) click to toggle source
# File lib/funneler.rb, line 26
def from_token(token:, current_page_index: nil)
  data = Funneler::TokenHandler.extract_data_from(token)
  Funneler::Funnel.new(data, current_page_index)
rescue JWT::DecodeError => e
  raise InvalidTokenError, "Invalid token '#{token}': #{e.message}"
end
from_url(url:) click to toggle source
# File lib/funneler.rb, line 46
def from_url(url:)
  uri = URI.parse(url)
  params = Hash[URI.decode_www_form(uri.query || "")]
  token = params['funnel_token']
  from_token(token: token)
end