Module: XamplGenerator::AttributeAsChild

Included in:
Element
Defined in:
lib/xamplr-gen/xampl-hand-generated.rb

Instance Method Summary collapse

Instance Method Details

#add_attribute(attribute) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 248

def add_attribute(attribute)
  accessed
  index = attribute.get_the_index
  if (nil == index) then
    throw "no value for the index 'name' of attribute defined in : " << attribute.pp_xml
  end

  existing = @attribute_child[index]

  self.remove_attribute(index) if existing and (existing != attribute)

  @children << attribute
  @attribute_child[index] = attribute

  attribute.add_parent(self)

  changed
  return attribute
end

#attribute_childObject Also known as: attribute



231
232
233
234
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 231

def attribute_child
  accessed
  @attribute_child
end

#attribute_child=(v) ⇒ Object Also known as: attribute=



236
237
238
239
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 236

def attribute_child=(v)
  accessed
  @attribute_child = v
end

#ensure_attribute(index) {|attribute| ... } ⇒ Object

Yields:



278
279
280
281
282
283
284
285
286
287
288
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 278

def ensure_attribute(index)
  accessed

  attribute = @attribute_child[index]
  return attribute if attribute

  attribute = Attribute.new(index) unless attribute

  yield(attribute) if block_given?
  return add_attribute(attribute)
end

#init_attribute_as_childObject



244
245
246
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 244

def init_attribute_as_child
  @attribute_child = IndexedArray.new
end

#new_attribute(index) {|attribute| ... } ⇒ Object

Yields:



268
269
270
271
272
273
274
275
276
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 268

def new_attribute(index)
  accessed

  attribute = nil
  attribute = Attribute.new(index) unless attribute

  yield(attribute) if block_given?
  return add_attribute(attribute)
end

#remove_attribute(index) ⇒ Object



290
291
292
293
294
295
296
297
298
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 290

def remove_attribute(index)
  accessed
  changed
  unless String === index or Symbol === index then
    index = index.get_the_index
  end
  attribute = @attribute_child.delete(index) if index
  @children.delete(attribute)
end