Class: Rail::Pipeline
- Inherits:
-
Object
- Object
- Rail::Pipeline
- Extended by:
- Forwardable
- Defined in:
- lib/rail/pipeline.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #find(asset) ⇒ Object
-
#initialize(config) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #process(request) ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/rail/pipeline.rb', line 5 def config @config end |
Instance Method Details
#find(asset) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rail/pipeline.rb', line 31 def find(asset) paths.each do |path| filename = File.join(path, asset) return filename if File.exist?(filename) end nil end |
#process(request) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rail/pipeline.rb', line 13 def process(request) context = Context.new(locals: { request: request }, mixins: loader.find) asset = rewrite(request.path) klass = Processor.find(asset) or raise NotFoundError asset = klass.extensify(asset) filename = find(asset) or raise NotFoundError processor = klass.new(self) body = processor.compile(filename, context: context) headers = { 'Content-Type' => klass.mime_type } [200, headers, Array(body)] rescue NotFoundError [404, {}, []] end |