Module: PandaPal::Concerns::AbilityHelper

Extended by:
ActiveSupport::Concern
Defined in:
lib/panda_pal/concerns/ability_helper.rb

Instance Method Summary collapse

Instance Method Details

#cache_on_session(*args, **kwargs, &blk) ⇒ Object



36
37
38
# File 'lib/panda_pal/concerns/ability_helper.rb', line 36

def cache_on_session(*args, **kwargs, &blk)
  panda_pal_session.cache(*args, **kwargs, &blk)
end

#is_lti_launch?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/panda_pal/concerns/ability_helper.rb', line 32

def is_lti_launch?
  panda_pal_session.present?
end

#panda_pal_sessionObject

Returns PandaPal::Session.

Returns:

  • PandaPal::Session



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/panda_pal/concerns/ability_helper.rb', line 8

def panda_pal_session
  @panda_pal_session ||= begin
                           raise "Ability class needs to set @panda_pal_session or @controller to use this feature" unless @controller.present?
                           @controller.current_session(create_missing: false)
                         end

  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

#rails_sessionObject



22
23
24
25
26
27
# File 'lib/panda_pal/concerns/ability_helper.rb', line 22

def rails_session
  @rails_session ||= begin
                       raise "Ability class needs to set @rails_session or @controller to use this feature" unless @controller.present?
                       @controller.session
                     end
end