Class: Dry::Schema::KeyCoercer Private
- Inherits:
-
Object
- Object
- Dry::Schema::KeyCoercer
- Extended by:
- Core::Cache
- Defined in:
- lib/dry/schema/key_coercer.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.
Coerces keys in a hash using provided coercer function
Constant Summary collapse
- TO_SYM =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:to_sym.to_proc.freeze
Instance Attribute Summary collapse
- #coercer ⇒ Object readonly private
- #key_map ⇒ Object readonly private
Class Method Summary collapse
- .new(*args, &coercer) ⇒ Object private
- .symbolized(*args) ⇒ Object private
Instance Method Summary collapse
- #call(source) ⇒ Object (also: #[]) private
-
#initialize(key_map, &coercer) ⇒ KeyCoercer
constructor
private
A new instance of KeyCoercer.
Constructor Details
#initialize(key_map, &coercer) ⇒ KeyCoercer
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 KeyCoercer.
28 29 30 |
# File 'lib/dry/schema/key_coercer.rb', line 28 def initialize(key_map, &coercer) @key_map = key_map.coercible(&coercer) end |
Instance Attribute Details
#coercer ⇒ 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.
15 16 17 |
# File 'lib/dry/schema/key_coercer.rb', line 15 def coercer @coercer end |
#key_map ⇒ 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.
15 16 17 |
# File 'lib/dry/schema/key_coercer.rb', line 15 def key_map @key_map end |
Class Method Details
.new(*args, &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.
18 19 20 |
# File 'lib/dry/schema/key_coercer.rb', line 18 def self.new(*args, &coercer) fetch_or_store(*args, coercer) { super(*args, &coercer) } end |
.symbolized(*args) ⇒ 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.
23 24 25 |
# File 'lib/dry/schema/key_coercer.rb', line 23 def self.symbolized(*args) new(*args, &TO_SYM) end |
Instance Method Details
#call(source) ⇒ Object Also known as: []
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.
33 34 35 |
# File 'lib/dry/schema/key_coercer.rb', line 33 def call(source) key_map.write(Hash(source)) end |