Class: Shale::Mapping::DictBase Private
- Inherits:
-
Object
- Object
- Shale::Mapping::DictBase
- Defined in:
- lib/shale/mapping/dict_base.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.
Base class for Mapping dictionary serialization formats (Hash/JSON/YAML/TOML/CSV)
Instance Attribute Summary collapse
-
#keys ⇒ Hash
readonly
private
Return keys mapping hash.
-
#root ⇒ Hash
readonly
private
Return hash for hash with properties for root Object.
Instance Method Summary collapse
-
#finalize! ⇒ Object
private
Set the “finalized” instance variable to true.
-
#finalized? ⇒ truem false
private
Query the “finalized” instance variable.
-
#initialize(render_nil_default: false) ⇒ DictBase
constructor
private
Initialize instance.
- #initialize_dup(other) ⇒ Object private
-
#map(key, to: nil, receiver: nil, using: nil, group: nil, render_nil: nil, schema: nil) ⇒ Object
private
Map key to attribute.
-
#properties(min_properties: nil, max_properties: nil, dependent_required: nil, additional_properties: nil) ⇒ Object
Allow schema properties to be set on the object.
Constructor Details
#initialize(render_nil_default: false) ⇒ DictBase
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.
Initialize instance
31 32 33 34 35 36 |
# File 'lib/shale/mapping/dict_base.rb', line 31 def initialize(render_nil_default: false) @keys = {} @root = {} @finalized = false @render_nil_default = render_nil_default end |
Instance Attribute Details
#keys ⇒ Hash (readonly)
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.
Return keys mapping hash
17 18 19 |
# File 'lib/shale/mapping/dict_base.rb', line 17 def keys @keys end |
#root ⇒ Hash (readonly)
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.
Return hash for hash with properties for root Object
24 25 26 |
# File 'lib/shale/mapping/dict_base.rb', line 24 def root @root end |
Instance Method Details
#finalize! ⇒ 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 the “finalized” instance variable to true
85 86 87 |
# File 'lib/shale/mapping/dict_base.rb', line 85 def finalize! @finalized = true end |
#finalized? ⇒ truem false
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.
Query the “finalized” instance variable
94 95 96 |
# File 'lib/shale/mapping/dict_base.rb', line 94 def finalized? @finalized end |
#initialize_dup(other) ⇒ 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.
99 100 101 102 103 |
# File 'lib/shale/mapping/dict_base.rb', line 99 def initialize_dup(other) @keys = other.instance_variable_get('@keys').dup @finalized = false super end |
#map(key, to: nil, receiver: nil, using: nil, group: nil, render_nil: nil, schema: 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 key to attribute
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/shale/mapping/dict_base.rb', line 51 def map(key, to: nil, receiver: nil, using: nil, group: nil, render_nil: nil, schema: nil) Validator.validate_arguments(key, to, receiver, using) @keys[key] = Descriptor::Dict.new( name: key, attribute: to, receiver: receiver, methods: using, group: group, render_nil: render_nil.nil? ? @render_nil_default : render_nil, schema: schema ) end |
#properties(min_properties: nil, max_properties: nil, dependent_required: nil, additional_properties: nil) ⇒ Object
Allow schema properties to be set on the object
73 74 75 76 77 78 79 80 |
# File 'lib/shale/mapping/dict_base.rb', line 73 def properties(min_properties: nil, max_properties: nil, dependent_required: nil, additional_properties: nil) @root = { min_properties: min_properties, max_properties: max_properties, dependent_required: dependent_required, additional_properties: additional_properties, } end |