Class: Wings::EnumerableMapper
- Inherits:
-
Valkyrie::ValueMapper
- Object
- Valkyrie::ValueMapper
- Wings::EnumerableMapper
- Defined in:
- lib/wings/transformer_value_mapper.rb
Overview
Note:
a common value type this mapper handles is ‘ActiveTriples::Relation`
Maps enumerable values (e.g. Array, Enumerable, Hash, etc…) by calling the parent ‘ValueMapper` on each member.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.handles?(value) ⇒ Boolean
72 73 74 |
# File 'lib/wings/transformer_value_mapper.rb', line 72 def self.handles?(value) value.is_a?(Enumerable) end |
Instance Method Details
#result ⇒ Enumerable<Object>
78 79 80 81 |
# File 'lib/wings/transformer_value_mapper.rb', line 78 def result return calling_mapper.for(value.first).result if value.length < 2 value.map { |v| calling_mapper.for(v).result } end |