Class: Lurker::Sandbox

Inherits:
Object
  • Object
show all
Defined in:
lib/lurker/sandbox.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Sandbox

Returns a new instance of Sandbox.



3
4
5
# File 'lib/lurker/sandbox.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/lurker/sandbox.rb', line 7

def call(env)
  orig_path = env['PATH_INFO']
  if orig_path.ends_with?('.js') || orig_path.ends_with?('css') || orig_path.ends_with?('css.map')
    @result = @app.call(env)
  else
    ActiveRecord::Base.transaction do
      @result = @app.call(env)
      raise ActiveRecord::Rollback if called_from_lurker?(env)
    end
  end
  @result
end