Class: Shale::Mapping::Dict Private

Inherits:
DictBase show all
Defined in:
lib/shale/mapping/dict.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 dictionary serialization formats (Hash/JSON/YAML/TOML/CSV)

Direct Known Subclasses

Shale::Mapping::Descriptor::Xml, Group::Xml

Instance Attribute Summary

Attributes inherited from DictBase

#keys, #root

Instance Method Summary collapse

Methods inherited from DictBase

#finalize!, #finalized?, #initialize, #initialize_dup, #properties

Constructor Details

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

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 keys to mapping methods

Parameters:

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


44
45
46
47
48
# File 'lib/shale/mapping/dict.rb', line 44

def group(from:, to:, &block)
  group = DictGroup.new(from, to)
  group.instance_eval(&block)
  @keys.merge!(group.keys)
end

#map(key, to: nil, receiver: nil, using: nil, render_nil: nil, schema: nil) ⇒ Object

Map key to attribute

Parameters:

  • key (String)

    Document’s key

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

Raises:



24
25
26
# File 'lib/shale/mapping/dict.rb', line 24

def map(key, to: nil, receiver: nil, using: nil, render_nil: nil, schema: nil)
  super(key, to: to, receiver: receiver, using: using, render_nil: render_nil, schema: schema)
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)


33
34
35
# File 'lib/shale/mapping/dict.rb', line 33

def render_nil(val)
  @render_nil_default = val
end