Sha256: 91f7ca94d34b35b6a15da0d513c0eba38642b8c85d158ac8f24ac6b302895d69
Contents?: true
Size: 1.6 KB
Versions: 11
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true module PandaPal::Concerns module AbilityHelper extend ActiveSupport::Concern # @return PandaPal::Session def panda_pal_session unless defined?(@panda_pal_session) || @controller.present? || method(:panda_pal_session).owner == PandaPal::Concerns::AbilityHelper raise "Ability class needs to set @panda_pal_session or @controller to use this feature" end @panda_pal_session = @controller.current_session(create_missing: false) unless defined?(@panda_pal_session) if @panda_pal_session.is_a?(Hash) # This is a breaking-change to CanvasSync, but not to PandaPal raise "Ability#panda_pal_session/@panda_pal_session should now return a PandaPal::Session object, not a Hash" end @panda_pal_session end def rails_session unless defined?(@rails_session) || @controller.present? || method(:rails_session).owner == PandaPal::Concerns::AbilityHelper raise "Ability class needs to set @rails_session or @controller to use this feature" end @rails_session ||= @controller.session unless defined?(@rails_session) end # Delegate legacy AbilityHelper methods to panda_pal_session. TODO Should such direct usage be considered deprecated? delegate :launch_params, :get_lti_cust_param, :lti_launch_placement, :canvas_site_admin?, :lti_roles, :canvas_role_labels, :canvas_account_role_labels, to: :panda_pal_session def is_lti_launch? panda_pal_session.present? end def cache_on_session(*args, **kwargs, &blk) panda_pal_session.cache(*args, **kwargs, &blk) end end end
Version data entries
11 entries across 11 versions & 1 rubygems