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



58
59
60
# File 'lib/panda_pal/concerns/ability_helper.rb', line 58

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

#is_lti_launch?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/panda_pal/concerns/ability_helper.rb', line 54

def is_lti_launch?
  panda_pal_session.present?
end

#panda_pal_sessionObject

Returns PandaPal::Session.

Returns:

  • PandaPal::Session



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/panda_pal/concerns/ability_helper.rb', line 28

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_panda_session 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

#rails_sessionObject



43
44
45
46
47
48
49
# File 'lib/panda_pal/concerns/ability_helper.rb', line 43

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