Class: BPM::Rack

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

Instance Method Summary collapse

Constructor Details

#initialize(app, project, opts = {}) ⇒ Rack

Returns a new instance of Rack.



3
4
5
6
7
8
9
# File 'lib/bpm/rack.rb', line 3

def initialize(app, project, opts={})
  mode = opts[:mode] || :debug

  @app = app
  @prefix = File.join('/', opts[:url_prefix] || '', 'assets')
  @pipeline = BPM::Pipeline.new(project, mode, true)
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/bpm/rack.rb', line 11

def call(env)
  if env['PATH_INFO'] =~ /^#{@prefix}\/(.+)$/
    env['PATH_INFO'] = $1
    @pipeline.call(env)
  else
    @app.call(env)
  end
end