Module: ContentfulModel::Manageable::ClassMethods

Defined in:
lib/contentful_model/manageable.rb

Overview

Management Class methods

Instance Method Summary collapse

Instance Method Details

#create(values = {}, publish = false) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/contentful_model/manageable.rb', line 145

def create(values = {}, publish = false)
  space = ContentfulModel.configuration.space
  environment = ContentfulModel.configuration.environment

  entry = management.entries(space, environment).create(
    management.content_types(space, environment).find(content_type_id),
    values
  )

  if publish
    entry.publish
    entry = find(entry.id)
  end

  entry
end

#management(options = {}) ⇒ Object



134
135
136
137
138
139
140
141
142
143
# File 'lib/contentful_model/manageable.rb', line 134

def management(options = {})
  @management ||= ContentfulModel::Management.new(
    options.merge(
      default_locale: ContentfulModel.configuration.default_locale,
      raise_errors: true,
      integration_name: 'contentful_model',
      integration_version: ::ContentfulModel::VERSION
    )
  )
end