Class: Contentful::Management::Space
- Inherits:
-
Object
- Object
- Contentful::Management::Space
- Includes:
- Resource, Resource::Refresher, Resource::SystemProperties
- Defined in:
- lib/contentful/management/space.rb
Overview
Resource class for Space.
Instance Attribute Summary collapse
-
#found_locale ⇒ Object
Returns the value of attribute found_locale.
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #properties, #raw_object, #request
Class Method Summary collapse
-
.all(client) ⇒ Contentful::Management::Array<Contentful::Management::Space>
Gets all Spaces.
-
.create(client, attributes) ⇒ Contentful::Management::Space
Create a space.
-
.find(client, space_id) ⇒ Contentful::Management::Space
Gets a specific space.
Instance Method Summary collapse
-
#api_keys ⇒ Contentful::Management::SpaceApiKeyMethodsFactory
Allows manipulation of api keys in context of the current space Allows listing all api keys of space, creating new and finding one by id.
-
#assets ⇒ Contentful::Management::SpaceAssetMethodsFactory
Allows manipulation of assets in context of the current space Allows listing all assets of space, creating new and finding one by id.
-
#content_types ⇒ Contentful::Management::SpaceContentTypeMethodsFactory
Allows manipulation of content types in context of the current space Allows listing all content types of space, creating new and finding one by id.
-
#default_locale ⇒ String
Retrieves Default Locale for current Space and leaves it cached.
-
#destroy ⇒ true, Contentful::Management::Error
Destroys a space.
-
#entries ⇒ Contentful::Management::SpaceEntryMethodsFactory
Allows manipulation of entries in context of the current space Allows listing all entries for space and finding one by id.
-
#find_locale ⇒ String
Finds Default Locale Code for current Space This request makes an API call to the Locale endpoint.
-
#locales ⇒ Contentful::Management::SpaceLocaleMethodsFactory
Allows manipulation of locales in context of the current space Allows listing all locales of space, creating new and finding one by id.
-
#save ⇒ Contentful::Management::Space
If a space is new, an object gets created in the Contentful, otherwise the existing space gets updated.
-
#update(attributes) ⇒ Contentful::Management::Space
Updates a space.
-
#webhooks ⇒ Contentful::Management::SpaceWebhookMethodsFactory
Allows manipulation of webhooks in context of the current space Allows listing all webhooks for space and finding one by id.
Methods included from Resource::Refresher
Methods included from Resource
#array?, #fields, #nested_locale_fields?, #resource?, #sys
Instance Attribute Details
#found_locale ⇒ Object
Returns the value of attribute found_locale.
28 29 30 |
# File 'lib/contentful/management/space.rb', line 28 def found_locale @found_locale end |
Class Method Details
.all(client) ⇒ Contentful::Management::Array<Contentful::Management::Space>
Gets all Spaces
41 42 43 |
# File 'lib/contentful/management/space.rb', line 41 def self.all(client) ClientSpaceMethodsFactory.new(client).all end |
.create(client, attributes) ⇒ Contentful::Management::Space
Create a space.
80 81 82 |
# File 'lib/contentful/management/space.rb', line 80 def self.create(client, attributes) ResourceRequester.new(client, self).create({}, attributes) end |
.find(client, space_id) ⇒ Contentful::Management::Space
Gets a specific space.
51 52 53 |
# File 'lib/contentful/management/space.rb', line 51 def self.find(client, space_id) ClientSpaceMethodsFactory.new(client).find(space_id) end |
Instance Method Details
#api_keys ⇒ Contentful::Management::SpaceApiKeyMethodsFactory
Allows manipulation of api keys in context of the current space Allows listing all api keys of space, creating new and finding one by id.
135 136 137 |
# File 'lib/contentful/management/space.rb', line 135 def api_keys SpaceApiKeyMethodsFactory.new(self) end |
#assets ⇒ Contentful::Management::SpaceAssetMethodsFactory
Allows manipulation of assets in context of the current space Allows listing all assets of space, creating new and finding one by id.
153 154 155 |
# File 'lib/contentful/management/space.rb', line 153 def assets SpaceAssetMethodsFactory.new(self) end |
#content_types ⇒ Contentful::Management::SpaceContentTypeMethodsFactory
Allows manipulation of content types in context of the current space Allows listing all content types of space, creating new and finding one by id.
126 127 128 |
# File 'lib/contentful/management/space.rb', line 126 def content_types SpaceContentTypeMethodsFactory.new(self) end |
#default_locale ⇒ String
Retrieves Default Locale for current Space and leaves it cached
178 179 180 |
# File 'lib/contentful/management/space.rb', line 178 def default_locale self.found_locale ||= find_locale end |
#destroy ⇒ true, Contentful::Management::Error
Destroys a space.
117 118 119 |
# File 'lib/contentful/management/space.rb', line 117 def destroy ResourceRequester.new(client, self.class).destroy(space_id: id) end |
#entries ⇒ Contentful::Management::SpaceEntryMethodsFactory
Allows manipulation of entries in context of the current space Allows listing all entries for space and finding one by id.
162 163 164 |
# File 'lib/contentful/management/space.rb', line 162 def entries SpaceEntryMethodsFactory.new(self) end |
#find_locale ⇒ String
Finds Default Locale Code for current Space This request makes an API call to the Locale endpoint
186 187 188 189 190 |
# File 'lib/contentful/management/space.rb', line 186 def find_locale locale = locales.all.detect(&:default) return locale.code unless locale.nil? @default_locale end |
#locales ⇒ Contentful::Management::SpaceLocaleMethodsFactory
Allows manipulation of locales in context of the current space Allows listing all locales of space, creating new and finding one by id.
144 145 146 |
# File 'lib/contentful/management/space.rb', line 144 def locales SpaceLocaleMethodsFactory.new(self) end |
#save ⇒ Contentful::Management::Space
If a space is new, an object gets created in the Contentful, otherwise the existing space gets updated.
105 106 107 108 109 110 111 112 |
# File 'lib/contentful/management/space.rb', line 105 def save if id update(name: name, organization_id: organization) else new_instance = self.class.create(client, name: name, organization_id: organization) refresh_data(new_instance) end end |
#update(attributes) ⇒ Contentful::Management::Space
Updates a space.
91 92 93 94 95 96 97 98 99 |
# File 'lib/contentful/management/space.rb', line 91 def update(attributes) ResourceRequester.new(client, self.class).update( self, { space_id: id }, { 'name' => attributes.fetch(:name) }, version: sys[:version], organization_id: attributes[:organization_id] ) end |
#webhooks ⇒ Contentful::Management::SpaceWebhookMethodsFactory
Allows manipulation of webhooks in context of the current space Allows listing all webhooks for space and finding one by id.
171 172 173 |
# File 'lib/contentful/management/space.rb', line 171 def webhooks SpaceWebhookMethodsFactory.new(self) end |