Module: ConDuxml::Instance

Included in:
Array, InstanceClass, Link
Defined in:
lib/con_duxml/instance.rb

Overview

Instances are copies of another XML element with a distinct set of parameter values like Objects in relation to a Class

Instance Method Summary collapse

Instance Method Details

#instantiateObject

creates copy of referent (found from context given by ‘meta’) at this element’s location



18
19
20
21
22
23
24
25
26
27
# File 'lib/con_duxml/instance.rb', line 18

def instantiate
  new_kids = []
  target = resolve_ref
  if target.nil?
    new_kids = nodes
  else
    new_kids << target.dclone
  end
  new_kids
end

#ref=(target) ⇒ Object

Raises:

  • (Exception)


8
9
10
11
# File 'lib/con_duxml/instance.rb', line 8

def ref=(target)
  raise Exception unless target.respond_to?(:nodes) or File.exists?(target)
  @ref = target
end

#resolve_ref(attr = nil) ⇒ Object



13
14
15
# File 'lib/con_duxml/instance.rb', line 13

def resolve_ref(attr=nil)
  @ref ||= self[attr || :ref]
end