Class: Shale::Mapping::Xml Private

Inherits:
XmlBase
  • Object
show all
Defined in:
lib/shale/mapping/xml.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Mapping for XML serialization format

Instance Attribute Summary

Attributes inherited from XmlBase

#attributes, #content, #default_namespace, #elements

Instance Method Summary collapse

Methods inherited from XmlBase

#finalize!, #finalized?, #initialize, #initialize_dup, #namespace, #prefixed_root, #root, #unprefixed_root

Constructor Details

This class inherits a constructor from Shale::Mapping::XmlBase

Instance Method Details

#group(from:, to:, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Map group of nodes to mapping methods

Parameters:

  • from (Symbol)
  • to (Symbol)
  • block (Proc)


105
106
107
108
109
110
111
112
113
114
# File 'lib/shale/mapping/xml.rb', line 105

def group(from:, to:, &block)
  group = XmlGroup.new(from, to)

  group.namespace(default_namespace.name, default_namespace.prefix)
  group.instance_eval(&block)

  @elements.merge!(group.elements)
  @attributes.merge!(group.attributes)
  @content = group.content if group.content
end

#map_attribute(attribute, to: nil, receiver: nil, using: nil, namespace: nil, prefix: nil, render_nil: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Map document’s attribute to object’s attribute

Parameters:

  • attribute (String)
  • to (Symbol, nil) (defaults to: nil)
  • receiver (Symbol, nil) (defaults to: nil)
  • using (Hash, nil) (defaults to: nil)
  • namespace (String, nil) (defaults to: nil)
  • prefix (String, nil) (defaults to: nil)
  • render_nil (true, false, nil) (defaults to: nil)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/shale/mapping/xml.rb', line 57

def map_attribute(
  attribute,
  to: nil,
  receiver: nil,
  using: nil,
  namespace: nil,
  prefix: nil,
  render_nil: nil
)
  super(
    attribute,
    to: to,
    receiver: receiver,
    using: using,
    namespace: namespace,
    prefix: prefix,
    render_nil: render_nil
  )
end

#map_content(to: nil, receiver: nil, using: nil, cdata: false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Map document’s content to object’s attribute

Parameters:

  • to (Symbol) (defaults to: nil)
  • receiver (Symbol, nil) (defaults to: nil)
  • using (Hash, nil) (defaults to: nil)
  • cdata (true, false) (defaults to: false)


85
86
87
# File 'lib/shale/mapping/xml.rb', line 85

def map_content(to: nil, receiver: nil, using: nil, cdata: false)
  super(to: to, receiver: receiver, using: using, cdata: cdata)
end

#map_element(element, to: nil, receiver: nil, using: nil, namespace: :undefined, prefix: :undefined, cdata: false, render_nil: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Map element to attribute

Parameters:

  • element (String)
  • to (Symbol, nil) (defaults to: nil)
  • receiver (Symbol, nil) (defaults to: nil)
  • using (Hash, nil) (defaults to: nil)
  • namespace (String, nil) (defaults to: :undefined)
  • prefix (String, nil) (defaults to: :undefined)
  • cdata (true, false) (defaults to: false)
  • render_nil (true, false, nil) (defaults to: nil)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/shale/mapping/xml.rb', line 24

def map_element(
  element,
  to: nil,
  receiver: nil,
  using: nil,
  namespace: :undefined,
  prefix: :undefined,
  cdata: false,
  render_nil: nil
)
  super(
    element,
    to: to,
    receiver: receiver,
    using: using,
    namespace: namespace,
    prefix: prefix,
    cdata: cdata,
    render_nil: render_nil
  )
end

#render_nil(val) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set render_nil default

Parameters:

  • val (true, false)


94
95
96
# File 'lib/shale/mapping/xml.rb', line 94

def render_nil(val)
  @render_nil_default = val
end