Class: Contentful::Management::Locale
- Inherits:
-
Object
- Object
- Contentful::Management::Locale
- Includes:
- Resource, Resource::Refresher, Resource::SystemProperties
- Defined in:
- lib/contentful/management/locale.rb
Overview
Resource class for Locale.
Constant Summary
Constants included from Resource::SystemProperties
Resource::SystemProperties::SYS_COERCIONS
Constants included from Resource
Instance Attribute Summary
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #default_locale, #properties, #raw_object, #request
Class Method Summary collapse
-
.all(space_id = nil, _parameters = {}) ⇒ Object
Gets a collection of locales.
-
.create(space_id, attributes) ⇒ Object
Creates a locale.
-
.find(space_id, locale_id) ⇒ Object
Gets a specific locale.
Instance Method Summary collapse
-
#update(attributes) ⇒ Object
Updates a locale.
Methods included from Resource::Refresher
Methods included from Resource::SystemProperties
included, #initialize, #inspect
Methods included from Resource
#array?, #fields, #initialize, #inspect, #nested_locale_fields?, #sys
Class Method Details
.all(space_id = nil, _parameters = {}) ⇒ Object
Gets a collection of locales. Takes an id of a space. Returns a Contentful::Management::Array of Contentful::Management::Locale.
20 21 22 23 24 25 |
# File 'lib/contentful/management/locale.rb', line 20 def self.all(space_id = nil, _parameters = {}) request = Request.new("/#{ space_id }/locales") response = request.get result = ResourceBuilder.new(response, {'Locale' => Locale}, {}) result.run end |
.create(space_id, attributes) ⇒ Object
Creates a locale. Takes a space id and hash with attributes:
:name
:code
:contentManagementApi
:contentDeliveryApi
:publish
Returns a Contentful::Management::Locale.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/contentful/management/locale.rb', line 45 def self.create(space_id, attributes) request = Request.new( "/#{ space_id }/locales", 'name' => attributes.fetch(:name), 'code' => attributes.fetch(:code) ) response = request.post result = ResourceBuilder.new(response, {'Locale' => Locale}, {}) result.run end |
.find(space_id, locale_id) ⇒ Object
Gets a specific locale. Takes an id of a space and locale id. Returns a Contentful::Management::Locale.
30 31 32 33 34 35 |
# File 'lib/contentful/management/locale.rb', line 30 def self.find(space_id, locale_id) request = Request.new("/#{ space_id }/locales/#{ locale_id }") response = request.get result = ResourceBuilder.new(response, {'Locale' => Locale}, {}) result.run end |
Instance Method Details
#update(attributes) ⇒ Object
Updates a locale. Takes a hash with attributes. Returns a Contentful::Management::Locale.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/contentful/management/locale.rb', line 59 def update(attributes) request = Request.new( "/#{ space.id }/locales/#{ id }", {'name' => attributes.fetch(:name)}, id = nil, version: sys[:version] ) response = request.put result = ResourceBuilder.new(response, {'Locale' => Locale}, {}) refresh_data(result.run) end |