Class: Wings::NestedResourceArrayValue

Inherits:
Valkyrie::ValueMapper
  • Object
show all
Defined in:
lib/wings/converter_value_mapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handles?(value) ⇒ Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/wings/converter_value_mapper.rb', line 198

def self.handles?(value)
  value.last.is_a?(Array) && value.last.any? { |x| x.is_a? Dry::Struct }
end

Instance Method Details

#resultObject



202
203
204
# File 'lib/wings/converter_value_mapper.rb', line 202

def result
  ["#{value.first}_attributes".to_sym, values]
end

#valuesObject



206
207
208
209
210
# File 'lib/wings/converter_value_mapper.rb', line 206

def values
  value.last.map do |val|
    calling_mapper.for([value.first, val]).result
  end.flat_map(&:last)
end