Class: ROXML::XMLRef
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.
21
22
23
24
|
# File 'lib/roxml/xml.rb', line 21
def initialize(opts, instance)
@opts = opts
@instance = instance
end
|
Instance Method Details
42
43
44
45
|
# File 'lib/roxml/xml.rb', line 42
def default
@default ||= @opts.default || (@opts.array? ? Array.new : nil)
@default.duplicable? ? @default.dup : @default
end
|
#name ⇒ Object
Also known as:
xpath_name
37
38
39
|
# File 'lib/roxml/xml.rb', line 37
def name
conventionize(opts.name)
end
|
26
27
28
29
|
# File 'lib/roxml/xml.rb', line 26
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
31
32
33
34
35
|
# File 'lib/roxml/xml.rb', line 31
def update_xml(xml, value)
returning wrap(xml) do |xml|
write_xml(xml, value)
end
end
|
#value_in(xml) ⇒ Object
47
48
49
50
|
# File 'lib/roxml/xml.rb', line 47
def value_in(xml)
value = fetch_value(xml)
freeze(apply_blocks(value))
end
|