Sha256: e98a6af61322d406a5e8645eb107e191ea6b34095d46f65b5d3aa4b4581c6048

Contents?: true

Size: 932 Bytes

Versions: 4

Compression:

Stored size: 932 Bytes

Contents

module CoalescingPanda
  module RouteHelpers
    def lti_nav(nav, *rest, &block)
      base_path = Rails.application.routes.named_routes[:coalescing_panda].path.spec
      raise LtiNavigationInUse.new('CoalescingPanda must be mounted before defining lti_nav routes') if base_path.blank?
      valid_options = [:course, :user, :account, :editor_button, :external_tool]
      if rest.empty? && nav.is_a?(Hash)
        options = nav
        nav, to = options.find {|name, _value| valid_options.include? name}
        options[:to] = to
        options.delete(nav)
      else
        options = rest.pop || {}
      end
      lti_options = options.delete(:lti_options) || {}
      path = "#{base_path}/#{nav.to_s}"
      lti_options[:url] = path.split('/').reject(&:empty?).join('_')
      post path, options, &block
      CoalescingPanda::register_navigation(nav)
      CoalescingPanda::lti_navigation(nav, lti_options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coalescing_panda-1.0.3 lib/coalescing_panda/route_helpers.rb
coalescing_panda-1.0.2 lib/coalescing_panda/route_helpers.rb
coalescing_panda-1.0.1 lib/coalescing_panda/route_helpers.rb
coalescing_panda-1.0.0 lib/coalescing_panda/route_helpers.rb