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.
12
13
14
15
|
# File 'lib/roxml/xml/references.rb', line 12
def initialize(opts, instance)
@opts = opts
@instance = instance
end
|
Instance Attribute Details
#opts ⇒ Object
9
10
11
|
# File 'lib/roxml/xml/references.rb', line 9
def opts
@opts
end
|
Instance Method Details
#blocks ⇒ Object
17
18
19
|
# File 'lib/roxml/xml/references.rb', line 17
def blocks
opts.blocks || []
end
|
#name ⇒ Object
26
27
28
|
# File 'lib/roxml/xml/references.rb', line 26
def name
opts.name_explicit? ? opts.name : conventionize(opts.name)
end
|
#to_xml(instance) ⇒ Object
21
22
23
24
|
# File 'lib/roxml/xml/references.rb', line 21
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
34
35
36
37
38
39
40
41
42
|
# File 'lib/roxml/xml/references.rb', line 34
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
30
31
32
|
# File 'lib/roxml/xml/references.rb', line 30
def xpath_name
namespacify(name)
end
|