Module: AbstractController::Collector
Class Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, &block) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'actionpack/lib/abstract_controller/collector.rb', line 21
def method_missing(symbol, &block)
mime_constant = Mime.const_get(symbol.to_s.upcase)
if Mime::SET.include?(mime_constant)
AbstractController::Collector.generate_method_for_mime(mime_constant)
send(symbol, &block)
else
super
end
end
|
Class Method Details
.generate_method_for_mime(mime) ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'actionpack/lib/abstract_controller/collector.rb', line 5
def self.generate_method_for_mime(mime)
sym = mime.is_a?(Symbol) ? mime : mime.to_sym
const = sym.to_s.upcase
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{sym}(*args, &block) # def html(*args, &block)
custom(Mime::#{const}, *args, &block) # custom(Mime::HTML, *args, &block)
end # end
RUBY
end
|