Class: AssetsOnHeroku::Rack
- Inherits:
-
Object
- Object
- AssetsOnHeroku::Rack
- Defined in:
- lib/assets_on_heroku.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
3 4 5 6 |
# File 'lib/assets_on_heroku.rb', line 3 def initialize(app) @app = app setup end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/assets_on_heroku.rb', line 8 def call(env) root = "tmp/public" path = ::Rack::Request.new(env).path is_stylesheet_request = path.start_with?("/stylesheets/") && path.end_with?(".css") is_javascript_request = path.start_with?("/javascripts/") && path.end_with?(".js") if is_stylesheet_request || is_javascript_request ::Rack::File.new(root).call(env) else @app.call(env) end end |