module AbstractController::Collector - actionpack-3.2.22 Documentation

# module AbstractController::Collector

### Public Class Methods

generate_method_for_mime(mime) click to toggle source

    # File 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 "        def #{sym}(*args, &block)                # def html(*args, &block)
              custom(Mime::#{const}, *args, &block)  #   custom(Mime::HTML, *args, &block)
            end                                      # end
    ", __FILE__, __LINE__ + 1
        end

### Protected Instance Methods

method_missing(symbol, &block) click to toggle source
Calls superclass method

    # File 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