Class: Crystal::Processors::EvaluateFormat

Inherits:
Crystal::Processor show all
Defined in:
lib/crystal/http/processors/evaluate_format.rb

Instance Attribute Summary

Attributes inherited from Crystal::Processor

#next_processor

Instance Method Summary collapse

Methods inherited from Crystal::Processor

#initialize, inspect

Constructor Details

This class inherits a constructor from Crystal::Processor

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/crystal/http/processors/evaluate_format.rb', line 4

def call
  path = workspace.path.must_be.defined
  params = workspace.params.must_be.defined
  
  parts = path.split('.')        
  if parts.size > 1
    format = parts.last
    logger.warn "Two :format parameters!" if params.include?(:format) 
    workspace.params = params.clone
    workspace.params.format = format
  else
    params.format ||= config.default_format!
  end
  
  next_processor.call
end