class XMLable::Handlers::Element
Public Class Methods
new(name, opts = {}, &block)
click to toggle source
@see XMLable::Handler::Base#initialize
Calls superclass method
XMLable::Mixins::Instantiable::new
# File lib/xmlable/handlers/element.rb, line 11 def initialize(name, opts = {}, &block) @container_type = opts.delete(:container) || Array super(name, opts, &block) end
Public Instance Methods
container_for_xml_element(parent)
click to toggle source
Create elements container for XML element
@parent [Nokogiri::XML::Element]
@return [#each]
# File lib/xmlable/handlers/element.rb, line 32 def container_for_xml_element(parent) container_proxy.new.tap do |c| c.__set_parent_node(parent) c.__set_handler(self) end end
container_proxy()
click to toggle source
Proxy class for elements objects
@return [Class]
# File lib/xmlable/handlers/element.rb, line 21 def container_proxy @container_proxy ||= Builder.container_proxy_for(@container_type) end
from_xml_element(element)
click to toggle source
Create element object from the XML element
@param [Nokogiri::XML::Element] element
@return [XMLable::Mixins::Object]
# File lib/xmlable/handlers/element.rb, line 84 def from_xml_element(element) Builder.build_element(element, self) end
inject_wraped(klass)
click to toggle source
@see XMLable::Handler::Base#inject_wraped
# File lib/xmlable/handlers/element.rb, line 42 def inject_wraped(klass) klass.class_eval do include XMLable::Mixins::ContentStorage include XMLable::Mixins::AttributesStorage include XMLable::Mixins::ElementsStorage include XMLable::Mixins::NamespaceDefinitionsStorage include XMLable::Mixins::BareValue include XMLable::Mixins::Instantiable end klass end
proxy()
click to toggle source
@see XMLable::Handler::Base#proxy
# File lib/xmlable/handlers/element.rb, line 57 def proxy @proxy ||= type_class.tap do |p| p.__default_namespace = namespace_prefix p.class_eval(&@block) if block_settings? end end
single?()
click to toggle source
Is this handler for multiple elements objects or not?
@return [Boolean]
# File lib/xmlable/handlers/element.rb, line 73 def single? true end