Class: Rack::LTI::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/lti/middleware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}, &block) ⇒ Middleware

Returns a new instance of Middleware.



9
10
11
12
# File 'lib/rack/lti/middleware.rb', line 9

def initialize(app, options = {}, &block)
  @app    = app
  @config = Config.new(options, &block)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/rack/lti/middleware.rb', line 7

def app
  @app
end

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/rack/lti/middleware.rb', line 7

def config
  @config
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/rack/lti/middleware.rb', line 14

def call(env)
  request = Rack::Request.new(env)

  if routes.has_key?(request.path)
    env['rack.lti'] = true
    send(routes[request.path], request, env)
  else
    @app.call(env)
  end
end

#routesObject



25
26
27
28
29
30
# File 'lib/rack/lti/middleware.rb', line 25

def routes
  {
    @config.config_path => :config_action,
    @config.launch_path => :launch_action
  }
end