1
require "action_dispatch/http/mime_type"
3
module AbstractController
5
def self.generate_method_for_mime(mime)
6
sym = mime.is_a?(Symbol) ? mime : mime.to_sym
7
const = sym.to_s.upcase
8
class_eval <<-RUBY, __FILE__, __LINE__ + 1
9
def #{sym}(*args, &block) # def html(*args, &block)
10
custom(Mime::#{const}, *args, &block) # custom(Mime::HTML, *args, &block)
15
Mime::SET.each do |mime|
16
generate_method_for_mime(mime)
21
def method_missing(symbol, &block)
22
mime_constant = Mime.const_get(symbol.to_s.upcase)
24
if Mime::SET.include?(mime_constant)
25
AbstractController::Collector.generate_method_for_mime(mime_constant)
b'\\ No newline at end of file'