Class: Nokogiri::XML::Builder
- Inherits:
-
Object
- Object
- Nokogiri::XML::Builder
- Defined in:
- lib/assert2/xhtml.rb
Instance Method Summary collapse
- #cleanse_element_name(method) ⇒ Object
-
#method_missing(method, *args, &block) ⇒ Object
monkey patch me!.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
monkey patch me!
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/assert2/xhtml.rb', line 376 def method_missing method, *args, &block # :nodoc: if @context && @context.respond_to?(method) @context.send(method, *args, &block) else node = Nokogiri::XML::Node.new(cleanse_element_name(method), @doc) { |n| args.each do |arg| case arg when Hash arg.each { |k,v| n[k.to_s] = v.to_s } else n.content = arg end end } insert(node, &block) end end |
Instance Method Details
#cleanse_element_name(method) ⇒ Object
372 373 374 |
# File 'lib/assert2/xhtml.rb', line 372 def cleanse_element_name(method) method.to_s.sub(/[_]$/, '') # or [_!] end |