Module: PandaPal::Helpers::RouteHelper

Defined in:
lib/panda_pal/helpers/route_helper.rb

Instance Method Summary collapse

Instance Method Details

#lti_nav(options, *rest, &block) ⇒ Object

Raises:



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/panda_pal/helpers/route_helper.rb', line 2

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