Module: ContentfulModel::Migrations::Migration
- Defined in:
- lib/contentful_model/migrations/migration.rb
Overview
Content Type Migration methods
Instance Method Summary collapse
- #add_content_type_field(content_type_id, name, type) {|field| ... } ⇒ Object
- #create_content_type(name, fields = {}, &block) ⇒ Object
- #remove_content_type_field(content_type_id, field_id) ⇒ Object
Instance Method Details
#add_content_type_field(content_type_id, name, type) {|field| ... } ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/contentful_model/migrations/migration.rb', line 12 def add_content_type_field(content_type_id, name, type, &_block) content_type = ContentfulModel::Migrations::ContentTypeFactory.find(content_type_id) field = content_type.field(name, type) yield(field) if block_given? content_type.save.publish end |
#create_content_type(name, fields = {}, &block) ⇒ Object
8 9 10 |
# File 'lib/contentful_model/migrations/migration.rb', line 8 def create_content_type(name, fields = {}, &block) ContentfulModel::Migrations::ContentTypeFactory.create(name, fields, &block) end |
#remove_content_type_field(content_type_id, field_id) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/contentful_model/migrations/migration.rb', line 21 def remove_content_type_field(content_type_id, field_id) content_type = ContentfulModel::Migrations::ContentTypeFactory.find(content_type_id) content_type.remove_field(field_id) content_type.save.publish end |