Class: Rubyang::Database::DataTree::List
Instance Attribute Summary
Attributes inherited from Node
#children, #parent, #schema, #schema_tree
Instance Method Summary
collapse
Methods inherited from Node
#evaluate_max_elements, #evaluate_min_elements, #evaluate_musts, #evaluate_whens, #evaluate_xpath, #evaluate_xpath_axis, #evaluate_xpath_expr, #evaluate_xpath_node_test, #evaluate_xpath_path, #evaluate_xpath_predicates, #initialize, #root, #to_json, #to_s, #to_xml, #valid?
Instance Method Details
#delete(*args) ⇒ Object
1010
1011
1012
1013
|
# File 'lib/rubyang/database/data_tree.rb', line 1010
def delete *args
child_node = @children.find{ |c| c.key_values == args }
@children.delete child_node
end
|
#edit(*args) ⇒ Object
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
|
# File 'lib/rubyang/database/data_tree.rb', line 998
def edit *args
child_node = @children.find{ |c| c.key_values == args }
unless child_node
begin
child_node = ListElement.new( self, @schema_tree, @schema, @db_mode, @ctx_mode, args )
rescue
raise ArgumentError, "#{args} NOT match"
end
@children.push child_node
end
child_node
end
|
#load_merge_xml_recursive(doc_xml) ⇒ Object
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
|
# File 'lib/rubyang/database/data_tree.rb', line 1027
def load_merge_xml_recursive doc_xml
return if doc_xml.elements.size == 0
key_args = @schema.keys.map{ |k| doc_xml.elements[k].text }
child = edit( *key_args )
elements = REXML::Document.new('<tmp />')
doc_xml.each_element{ |e|
next if @schema.keys.include? e.name
elements.root.add_element e
}
child.load_merge_xml_recursive elements.root
end
|
#to_json_recursive(_hash) ⇒ Object
1020
1021
1022
1023
1024
1025
1026
|
# File 'lib/rubyang/database/data_tree.rb', line 1020
def to_json_recursive _hash
array = Array.new
_hash[@schema.model.arg] = array
@children.each{ |c|
c.to_json_recursive array
}
end
|
#to_xml_recursive(_doc, current_namespace) ⇒ Object
1014
1015
1016
1017
1018
1019
|
# File 'lib/rubyang/database/data_tree.rb', line 1014
def to_xml_recursive _doc, current_namespace
doc = _doc
@children.each{ |c|
c.to_xml_recursive doc, current_namespace
}
end
|