Class: Dry::Schema::Key::Array Private

Inherits:
Dry::Schema::Key show all
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

DEFAULT_COERCER

Instance Attribute Summary collapse

Attributes inherited from Dry::Schema::Key

#coercer, #id, #name

Instance Method Summary collapse

Methods inherited from Dry::Schema::Key

[], new, #new, #read

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.



138
139
140
141
# File 'lib/dry/schema/key.rb', line 138

def initialize(id, member:, **opts)
  super(id, **opts)
  @member = member
end

Instance Attribute Details

#memberObject (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.



135
136
137
# File 'lib/dry/schema/key.rb', line 135

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.



151
152
153
# File 'lib/dry/schema/key.rb', line 151

def coercible(&coercer)
  new(coercer: coercer, member: member.coercible(&coercer))
end

#dumpObject

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.



161
162
163
# File 'lib/dry/schema/key.rb', line 161

def dump
  [name, member.dump]
end

#stringifiedObject

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.



156
157
158
# File 'lib/dry/schema/key.rb', line 156

def stringified
  new(name: name.to_s, member: member.stringified)
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.



144
145
146
147
148
# File 'lib/dry/schema/key.rb', line 144

def write(source, target)
  read(source) { |value|
    target[coerced_name] = value.is_a?(::Array) ? value.map { |el| member.write(el) } : value
  }
end