Class: Darlingtonia::HashMapper
- Inherits:
-
MetadataMapper
- Object
- MetadataMapper
- Darlingtonia::HashMapper
- Defined in:
- lib/darlingtonia/hash_mapper.rb
Overview
A generic metadata mapper for input records
Maps from hash accessor syntax (‘[’title’]‘) to method call dot syntax (`.title`)
The fields provided by this mapper are dynamically determined by the fields available in the provided metadata hash.
All field values are given as multi-valued arrays.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from MetadataMapper
Instance Method Summary collapse
-
#fields ⇒ Enumerable<Symbol>
The fields the mapper can process.
- #map_field(name) ⇒ Object
- #metadata=(meta) ⇒ Hash<String, String>
Methods inherited from MetadataMapper
#field?, #method_missing, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Darlingtonia::MetadataMapper
Instance Method Details
#fields ⇒ Enumerable<Symbol>
Returns The fields the mapper can process.
33 34 35 36 |
# File 'lib/darlingtonia/hash_mapper.rb', line 33 def fields return [] if .nil? .keys.map(&:to_sym) end |
#map_field(name) ⇒ Object
40 41 42 |
# File 'lib/darlingtonia/hash_mapper.rb', line 40 def map_field(name) Array([name.to_s]) end |
#metadata=(meta) ⇒ Hash<String, String>
27 28 29 |
# File 'lib/darlingtonia/hash_mapper.rb', line 27 def () @metadata = .to_h end |