Method: Contentful::Management::ResourceBuilder#create_resource

Defined in:
lib/contentful/management/resource_builder.rb

#create_resource(object) ⇒ Object

Creates a single resource from the response object


116
117
118
119
120
121
122
123
124
125
126
# File 'lib/contentful/management/resource_builder.rb', line 116

def create_resource(object)
  res_class = detect_resource_class(object)
  @nested_locales ||= res_class.nested_locale_fields?
  res = res_class.new(object, response.request, client, @nested_locales)

  add_to_known_resources res
  replace_children res, object
  replace_child_array res.items if res.array?

  res
end