Method: Unit::Types::RelationshipArray.from_params_array

Defined in:
lib/unit/types/relationship_array.rb

.from_params_array(array) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/unit/types/relationship_array.rb', line 18

def self.from_params_array(array)
  @relationships = []
  array.map do |item|
    @relationships << if item.is_a?(Relationship)
                        item.to_hash[:data]
                      else
                        Relationship.new(item[:type], item[:id]).to_hash[:data] end
  end
  RelationshipArray.new(@relationships).to_hash
end