Class: Sinatra::RespondTo::Helpers::Format

Inherits:
Array
  • Object
show all
Defined in:
lib/sinatra/respond_to.rb

Overview

NOTE Array instead of hash because order matters (wildcard type matches first handler)

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(format, *args, &handler) ⇒ Object

:nodoc:



259
260
261
262
263
264
265
# File 'lib/sinatra/respond_to.rb', line 259

def method_missing(format, *args, &handler)
  mt = Sinatra::RespondTo::Helpers.mime_type(format)
  if mt.nil?
    Sinatra::Base.send(:fail, "Unknown media type for respond_to: #{format}\nTry registering the extension with a mime type")
  end
  self << [format.to_s, mt, handler]
end