Class: ROXML::XMLRef
- Inherits:
-
Object
show all
- Defined in:
- lib/roxml/xml/references.rb
Overview
Internal base class that represents an XML - Class binding.
Instance Method Summary
collapse
Constructor Details
#initialize(opts, instance) ⇒ XMLRef
Returns a new instance of XMLRef.
11
12
13
14
|
# File 'lib/roxml/xml/references.rb', line 11
def initialize(opts, instance)
@opts = opts
@instance = instance
end
|
Instance Method Details
#name ⇒ Object
27
28
29
|
# File 'lib/roxml/xml/references.rb', line 27
def name
opts.name_explicit? ? opts.name : conventionize(opts.name)
end
|
#to_xml ⇒ Object
16
17
18
19
|
# File 'lib/roxml/xml/references.rb', line 16
def to_xml
val = @instance.__send__(accessor)
opts.to_xml.respond_to?(:call) ? opts.to_xml.call(val) : val
end
|
#update_xml(xml, value) ⇒ Object
21
22
23
24
25
|
# File 'lib/roxml/xml/references.rb', line 21
def update_xml(xml, value)
returning wrap(xml) do |xml|
write_xml(xml, value)
end
end
|
#value_in(xml) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/roxml/xml/references.rb', line 39
def value_in(xml)
xml = XML::Node.from(xml)
value = fetch_value(xml)
value = default if value.nil?
freeze(apply_blocks(value))
end
|
#xpath_name ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/roxml/xml/references.rb', line 31
def xpath_name
if !opts.name_explicit? && namespace = @instance.class.roxml_namespace
"#{namespace}:#{name}"
else
name
end
end
|