mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
27 lines
467 B
Ruby
27 lines
467 B
Ruby
|
module Sinatra
|
||
|
|
||
|
module Responder
|
||
|
|
||
|
def self.included(parent)
|
||
|
parent.send(:include, InstanceMethods)
|
||
|
end
|
||
|
|
||
|
class ResponderContext
|
||
|
def initialize(format)
|
||
|
@format = format
|
||
|
end
|
||
|
|
||
|
def method_missing(name, *args)
|
||
|
yield if name.to_s == @format
|
||
|
end
|
||
|
end
|
||
|
|
||
|
module InstanceMethods
|
||
|
def format
|
||
|
@responder_context ||= ResponderContext.new(params[:format])
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
end
|