class LazyXmlModel::ElementProxy
Attributes
element_tag[R]
xml_document[R]
xml_parent_element[R]
Public Class Methods
new(element_tag, xml_document, xml_parent_element)
click to toggle source
# File lib/lazy_xml_model/element_proxy.rb, line 5 def initialize(element_tag, xml_document, xml_parent_element) @element_tag = element_tag @xml_document = xml_document @xml_parent_element = xml_parent_element end
Public Instance Methods
value()
click to toggle source
Getter Method
# File lib/lazy_xml_model/element_proxy.rb, line 12 def value if xml_element.present? xml_element.children.first.content end end
value=(value)
click to toggle source
Setter Method
# File lib/lazy_xml_model/element_proxy.rb, line 19 def value=(value) if xml_element.present? xml_element.children.first.content = value else xml_element = Nokogiri::XML::Element.new(element_tag.to_s, xml_document) xml_element.content = value xml_parent_element.add_child(xml_element) end end
Private Instance Methods
xml_element()
click to toggle source
# File lib/lazy_xml_model/element_proxy.rb, line 31 def xml_element xml_parent_element.elements.find { |element| element.name == element_tag.to_s } end