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) ⇒ Object private
- .symbolized(*args) ⇒ Object private
Instance Method Summary collapse
- #call(result) ⇒ 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.
30 31 32 |
# File 'lib/dry/schema/key_coercer.rb', line 30 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.
17 18 19 |
# File 'lib/dry/schema/key_coercer.rb', line 17 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.
17 18 19 |
# File 'lib/dry/schema/key_coercer.rb', line 17 def key_map @key_map end |
Class Method Details
.new(*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.
20 21 22 |
# File 'lib/dry/schema/key_coercer.rb', line 20 def self.new(*args) fetch_or_store(*args) { super } 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.
25 26 27 |
# File 'lib/dry/schema/key_coercer.rb', line 25 def self.symbolized(*args) new(*args, &TO_SYM) end |
Instance Method Details
#call(result) ⇒ 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.
35 36 37 |
# File 'lib/dry/schema/key_coercer.rb', line 35 def call(result) key_map.write(result.to_h) end |