123456789_123456789_123456789_123456789_123456789_

Class: ActionView::Helpers::AtomFeedHelper::AtomBuilder

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: actionview/lib/action_view/helpers/atom_feed_helper.rb

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.new(xml) ⇒ AtomBuilder

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/atom_feed_helper.rb', line 132

def initialize(xml)
  @xml = xml
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) (private)

Delegate to XML Builder, first wrapping the element in an XHTML namespaced div element if the method and arguments indicate that an xhtml_block? is desired.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/atom_feed_helper.rb', line 140

def method_missing(method, *arguments, &block)
  if xhtml_block?(method, arguments)
    @xml.__send__(method, *arguments) do
      @xml.div(xmlns: "http://www.w3.org/1999/xhtml") do |xhtml|
        block.call(xhtml)
      end
    end
  else
    @xml.__send__(method, *arguments, &block)
  end
end

Instance Method Details

#xhtml_block?(method, arguments) ⇒ Boolean (private)

True if the method name matches one of the five elements defined in the Atom spec as potentially containing XHTML content and if type: ‘xhtml’ is, in fact, specified.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/atom_feed_helper.rb', line 155

def xhtml_block?(method, arguments)
  if XHTML_TAG_NAMES.include?(method.to_s)
    last = arguments.last
    last.is_a?(Hash) && last[:type].to_s == "xhtml"
  end
end