Class: Ext::NegociateContent::ContentSelector
- Defined in:
- lib/ext/negociate_content.rb
Overview
TODO : Set the Content-Type that was selected.
Instance Method Summary collapse
-
#initialize(env) ⇒ ContentSelector
constructor
A new instance of ContentSelector.
-
#method_missing(m) ⇒ Object
TODO : Complete this.
Constructor Details
#initialize(env) ⇒ ContentSelector
Returns a new instance of ContentSelector.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ext/negociate_content.rb', line 25 def initialize(env) @accept = prioritize(env.HTTP_ACCEPT || '*/*').inject([]) do |arr, mime| arr.push *MIME::Types[mime] arr end # Prioritize according to the extension if data = /\.(.+)$/.match(e['PATH_INFO']) and types = MIME::Types.of(data[1]) types.each do |type| if @accept.include? type @accept.delete(type) @accept.unshift(type) end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m) ⇒ Object
TODO : Complete this
43 44 45 |
# File 'lib/ext/negociate_content.rb', line 43 def method_missing(m) yield end |