Method: Contentful::Importer::ContentfulModelToJson#create_content_type_fields

Defined in:
lib/contentful/importer/converters/contentful_model_to_json.rb

#create_content_type_fields(content_type) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/contentful/importer/converters/contentful_model_to_json.rb', line 47

def create_content_type_fields(content_type)
  content_type['fields'].each_with_object({}) do |(field, _value), results|
    id = link_id(field)
    results[id] = case field['type']
                    when 'Link'
                      {id: field['id'], type: field['linkType'], link: 'Link'}
                    when 'Array'
                      {id: field['id'], type: field['type'], link_type: field['items']['linkType'], link: field['items']['type']}
                    else
                      field['type']
                  end
  end
end