instance method method_missing

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

method_missing(sym, *args, &block)

Create XML markup based on the name of the method. This method is never invoked directly, but is called for each markup method in the markup block.

Parameters

sym req
args rest
block block
Source
# File activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb, line 37
    def method_missing(sym, *args, &block)
      text = nil
      attrs = nil
      sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
      args.each do |arg|
        case arg
        when Hash
          attrs ||= {}
          attrs.merge!(arg)
        else
          text ||= ''
          text << arg.to_s
        end
      end
      if block
        unless text.nil?
          raise ArgumentError, "XmlMarkup cannot mix a text argument with a block"
        end
        _indent
        _start_tag(sym, attrs)
        _newline
        _nested_structures(block)
        _indent
        _end_tag(sym)
        _newline
      elsif text.nil?
        _indent
        _start_tag(sym, attrs, true)
        _newline
      else
        _indent
        _start_tag(sym, attrs)
        text! text
        _end_tag(sym)
        _newline
      end
      @target
    end

Defined in activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb line 37 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Builder::XmlBase

Type at least 2 characters to search.

↑↓ navigate · open · esc close