Class: Contentful::Management::UIExtension
- Inherits:
-
Object
- Object
- Contentful::Management::UIExtension
- Defined in:
- lib/contentful/management/ui_extension.rb
Overview
Resource class for UIExtension.
Instance Attribute Summary
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #default_locale, #properties, #raw_object, #request
Instance Method Summary collapse
-
#field_types ⇒ Array<String>
Returns extension field types.
-
#field_types=(values) ⇒ Object
Sets extension field types.
-
#name ⇒ String
Returns extension name.
-
#name=(value) ⇒ Object
Sets extension name.
-
#parameters ⇒ Hash
Returns extensions parameters.
-
#parameters=(value) ⇒ Object
Sets extension parameters.
-
#save ⇒ Contentful::Management::UIExtension
If an extension is a new object gets created in the Contentful, otherwise the existing extension gets updated.
-
#sidebar ⇒ Boolean
Returns if extension is on sidebar.
-
#sidebar=(value) ⇒ Object
Sets if extension is on sidebar.
-
#source ⇒ String
Returns extension source URL or data.
-
#source=(value) ⇒ Object
Sets extension source.
Methods included from Resource::EnvironmentAware
Methods included from Resource::Refresher
Methods included from Resource
#array?, #destroy, #environment_id, #fields, #nested_locale_fields?, #resource?, #sys, #update
Instance Method Details
#field_types ⇒ Array<String>
Returns extension field types
67 68 69 |
# File 'lib/contentful/management/ui_extension.rb', line 67 def field_types extension['fieldTypes'] end |
#field_types=(values) ⇒ Object
Sets extension field types
73 74 75 |
# File 'lib/contentful/management/ui_extension.rb', line 73 def field_types=(values) extension['fieldTypes'] = values end |
#name ⇒ String
Returns extension name
55 56 57 |
# File 'lib/contentful/management/ui_extension.rb', line 55 def name extension['name'] end |
#name=(value) ⇒ Object
Sets extension name
61 62 63 |
# File 'lib/contentful/management/ui_extension.rb', line 61 def name=(value) extension['name'] = value end |
#parameters ⇒ Hash
Returns extensions parameters
109 110 111 |
# File 'lib/contentful/management/ui_extension.rb', line 109 def parameters extension['parameters'] end |
#parameters=(value) ⇒ Object
Sets extension parameters
115 116 117 |
# File 'lib/contentful/management/ui_extension.rb', line 115 def parameters=(value) extension['parameters'] = value end |
#save ⇒ Contentful::Management::UIExtension
If an extension is a new object gets created in the Contentful, otherwise the existing extension gets updated.
43 44 45 46 47 48 49 50 51 |
# File 'lib/contentful/management/ui_extension.rb', line 43 def save self.class.valid_extension(extension) if id update(extension: extension) else new_instance = self.class.create(client, sys[:space].id, environment_id, extension: extension) refresh_data(new_instance) end end |
#sidebar ⇒ Boolean
Returns if extension is on sidebar
97 98 99 |
# File 'lib/contentful/management/ui_extension.rb', line 97 def extension['sidebar'] end |
#sidebar=(value) ⇒ Object
Sets if extension is on sidebar
103 104 105 |
# File 'lib/contentful/management/ui_extension.rb', line 103 def (value) extension['sidebar'] = value end |
#source ⇒ String
Returns extension source URL or data
79 80 81 |
# File 'lib/contentful/management/ui_extension.rb', line 79 def source extension['src'] || extension['srcdoc'] end |
#source=(value) ⇒ Object
Sets extension source
85 86 87 88 89 90 91 92 93 |
# File 'lib/contentful/management/ui_extension.rb', line 85 def source=(value) if value.start_with?('http') extension['src'] = value extension.delete('srcdoc') else extension['srcdoc'] = value extension.delete('src') end end |