Class: Rubyang::Database::DataTree::ListElement
- Inherits:
-
InteriorNode
- Object
- Node
- InteriorNode
- Rubyang::Database::DataTree::ListElement
- Defined in:
- lib/rubyang/database/data_tree.rb
Instance Attribute Summary
Attributes inherited from Node
#children, #parent, #schema, #schema_tree
Instance Method Summary collapse
- #edit(arg, in_initialize = false) ⇒ Object
-
#initialize(parent, schema_tree, schema, db_mode, ctx_mode, key_values) ⇒ ListElement
constructor
A new instance of ListElement.
- #key_values ⇒ Object
- #to_json_recursive(_array) ⇒ Object
Methods inherited from InteriorNode
#delete, #delete_same_choice_other_case, #edit_xpath, #find_child_schema, #to_xml_recursive
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, #load_merge_xml_recursive, #root, #to_json, #to_s, #to_xml, #valid?
Constructor Details
#initialize(parent, schema_tree, schema, db_mode, ctx_mode, key_values) ⇒ ListElement
Returns a new instance of ListElement.
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 |
# File 'lib/rubyang/database/data_tree.rb', line 1041 def initialize parent, schema_tree, schema, db_mode, ctx_mode, key_values @logger = Logger.new(self.class.name) @parent = parent @schema_tree = schema_tree @schema = schema @db_mode = db_mode @ctx_mode = ctx_mode @children = [] @key_values = key_values @schema.keys.zip( key_values ).each{ |key, value| self.edit( key, true ).set( value ) } end |
Instance Method Details
#edit(arg, in_initialize = false) ⇒ Object
1057 1058 1059 1060 1061 1062 1063 1064 |
# File 'lib/rubyang/database/data_tree.rb', line 1057 def edit arg, in_initialize=false unless in_initialize if @schema.model.substmt( 'key' ).find{ |s| s.arg == arg } raise "#{arg} is key" end end super arg end |
#key_values ⇒ Object
1054 1055 1056 |
# File 'lib/rubyang/database/data_tree.rb', line 1054 def key_values @key_values end |
#to_json_recursive(_array) ⇒ Object
1065 1066 1067 1068 1069 1070 1071 |
# File 'lib/rubyang/database/data_tree.rb', line 1065 def to_json_recursive _array hash = Hash.new _array.push hash @children.each{ |c| c.to_json_recursive hash } end |