class ContentfulMigrations::MigrationContentType
Constants
- DEFAULT_MIGRATION_CONTENT_TYPE
Attributes
access_token[R]
client[R]
logger[R]
migration_content_type_name[R]
space[R]
space_id[R]
Public Class Methods
new(client:, space:, logger:, migration_content_type_name: DEFAULT_MIGRATION_CONTENT_TYPE)
click to toggle source
# File lib/contentful_migrations/migration_content_type.rb, line 8 def initialize(client:, space:, logger:, migration_content_type_name: DEFAULT_MIGRATION_CONTENT_TYPE) @client = client @space = space @logger = logger @migration_content_type_name = migration_content_type_name end
Public Instance Methods
resolve()
click to toggle source
# File lib/contentful_migrations/migration_content_type.rb, line 18 def resolve @migration_content_type ||= find_or_create_migration_content_type end
Private Instance Methods
build_migration_content_type()
click to toggle source
# File lib/contentful_migrations/migration_content_type.rb, line 33 def build_migration_content_type content_type = space.content_types.create( name: migration_content_type_name, id: migration_content_type_name, description: 'Migration Table for interal use only, do not delete' ) content_type.fields.create(id: 'version', name: 'version', type: 'Integer') content_type.save content_type.publish content_type end
find_or_create_migration_content_type()
click to toggle source
# File lib/contentful_migrations/migration_content_type.rb, line 24 def find_or_create_migration_content_type content_type = space.content_types.find(migration_content_type_name) if content_type.nil? || content_type.is_a?(Contentful::Management::Error) build_migration_content_type else content_type end end