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 Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts, instance) ⇒ XMLRef
Returns a new instance of XMLRef.
14
15
16
17
|
# File 'lib/roxml/xml/references.rb', line 14
def initialize(opts, instance)
@opts = opts
@instance = instance
end
|
Instance Attribute Details
#opts ⇒ Object
11
12
13
|
# File 'lib/roxml/xml/references.rb', line 11
def opts
@opts
end
|
Instance Method Details
#blocks ⇒ Object
19
20
21
|
# File 'lib/roxml/xml/references.rb', line 19
def blocks
opts.blocks || []
end
|
#name ⇒ Object
28
29
30
|
# File 'lib/roxml/xml/references.rb', line 28
def name
opts.name_explicit? ? opts.name : conventionize(opts.name)
end
|
#to_xml(instance) ⇒ Object
23
24
25
26
|
# File 'lib/roxml/xml/references.rb', line 23
def to_xml(instance)
val = instance.__send__(accessor)
opts.to_xml.respond_to?(:call) ? opts.to_xml.call(val) : val
end
|
#value_in(xml) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/roxml/xml/references.rb', line 36
def value_in(xml)
xml = XML::Node.from(xml)
value = fetch_value(xml)
value = default if default && (value.nil? || value.to_s.empty?)
value = apply_blocks(value)
value = freeze(value) if value && opts.frozen?
value
end
|
#xpath_name ⇒ Object
32
33
34
|
# File 'lib/roxml/xml/references.rb', line 32
def xpath_name
namespacify(name)
end
|