Class: Dry::Schema::Key::Array Private
- Inherits:
-
Dry::Schema::Key
- Object
- Dry::Schema::Key
- Dry::Schema::Key::Array
- Defined in:
- lib/dry/schema/key.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.
A specialized key type which handles nested arrays
Constant Summary
Constants inherited from Dry::Schema::Key
Instance Attribute Summary collapse
- #member ⇒ Object readonly private
Attributes inherited from Dry::Schema::Key
Instance Method Summary collapse
- #coercible(&coercer) ⇒ Object private
- #dump ⇒ Object private
-
#initialize(id, member:, **opts) ⇒ Array
constructor
private
A new instance of Array.
- #stringified ⇒ Object private
- #to_dot_notation ⇒ Object private
- #write(source, target) ⇒ Object private
Methods inherited from Dry::Schema::Key
Constructor Details
#initialize(id, member:, **opts) ⇒ Array
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.
Returns a new instance of Array.
145 146 147 148 |
# File 'lib/dry/schema/key.rb', line 145 def initialize(id, member:, **opts) super(id, **opts) @member = member end |
Instance Attribute Details
#member ⇒ Object (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.
142 143 144 |
# File 'lib/dry/schema/key.rb', line 142 def member @member end |
Instance Method Details
#coercible(&coercer) ⇒ 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.
163 164 165 |
# File 'lib/dry/schema/key.rb', line 163 def coercible(&coercer) new(coercer: coercer, member: member.coercible(&coercer)) end |
#dump ⇒ 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.
178 179 180 |
# File 'lib/dry/schema/key.rb', line 178 def dump [name, member.dump] end |
#stringified ⇒ 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.
168 169 170 |
# File 'lib/dry/schema/key.rb', line 168 def stringified new(name: name.to_s, member: member.stringified) end |
#to_dot_notation ⇒ 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.
173 174 175 |
# File 'lib/dry/schema/key.rb', line 173 def to_dot_notation [:"#{name}[]"].product(member.to_dot_notation).map { |el| el.join(DOT) } end |
#write(source, target) ⇒ 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.
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/dry/schema/key.rb', line 151 def write(source, target) read(source) { |value| target[coerced_name] = if value.is_a?(::Array) value.map { |el| el.is_a?(::Hash) ? member.write(el) : el } else value end } end |