Sha256: b2b5cacce09bcbeffbf7e797f80c6a5379807384107bc632ccdaad783e2defd5

Contents?: true

Size: 975 Bytes

Versions: 20

Compression:

Stored size: 975 Bytes

Contents

module PandaPal::Helpers::RouteHelper
  def lti_nav(options, *rest, &block)
    base_path = Rails.application.routes.named_routes[:panda_pal].path.spec
    raise LtiNavigationInUse.new('PandaPal must be mounted before defining lti_nav routes') if base_path.blank?

    nav, to = options.first
    options[:to] = to
    options.delete nav
    path = "#{base_path}/#{nav.to_s}"

    lti_options = options.delete(:lti_options) || {}

    lti_options[:auto_launch] = options.delete(:auto_launch)
    # NB if lti_nav is outside an :organization_id scope, auto_launch defaults differently between 1.1 and 1.3 - 1.1 defaults off, 1.3 defaults on
    lti_options[:auto_launch] = true if lti_options[:auto_launch].nil? && (@scope[:path] || '').include?(':organization_id')

    lti_options[:route_helper_key] = path.split('/').reject(&:empty?).join('_')
    post(path, options.dup, &block)
    get(path, options.dup, &block)
    PandaPal::stage_navigation(nav, lti_options)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
panda_pal-5.12.7 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.6 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.5 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.4 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.3 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.2 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.1 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.12.0 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.11.0 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.10.1 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.10.0 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.8.beta1 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.7 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.6 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.5 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.4 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.3 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.1 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.9.0 lib/panda_pal/helpers/route_helper.rb
panda_pal-5.8.5 lib/panda_pal/helpers/route_helper.rb