Method: ContentfulModel::Migrations::ContentTypeFactory.create

Defined in:
lib/contentful_model/migrations/content_type_factory.rb

.create(name, fields = {}) {|content_type| ... } ⇒ Object

Yields:

  • (content_type)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/contentful_model/migrations/content_type_factory.rb', line 7

def self.create(name, fields = {}, &_block)
  content_type = ContentfulModel::Migrations::ContentType.new(name)

  yield(content_type) if block_given?

  fields.each do |field_name, type|
    content_type.field(field_name, type)
  end

  content_type.save
end