Class: Contentful::Management::UIExtension

Inherits:
Object
  • Object
show all
Includes:
Resource, Resource::EnvironmentAware, Resource::Refresher, Resource::SystemProperties
Defined in:
lib/contentful/management/ui_extension.rb

Overview

Resource class for UIExtension.

See Also:

  • https://www.contentful.com/developers/docs/references/content-management-api/#/reference/ui-extensions

Instance Attribute Summary

Attributes included from Resource::SystemProperties

#sys

Attributes included from Resource

#client, #properties, #raw_object, #request

Instance Method Summary collapse

Methods included from Resource::EnvironmentAware

#environment_id

Methods included from Resource::Refresher

#reload

Methods included from Resource

#array?, #default_locale, #destroy, #environment_id, #fields, #nested_locale_fields?, #resource?, #sys, #update

Instance Method Details

#field_typesArray<String>

Returns extension field types

Returns:

  • (Array<String>)

    field types



66
67
68
# File 'lib/contentful/management/ui_extension.rb', line 66

def field_types
  extension['fieldTypes']
end

#field_types=(values) ⇒ Object

Sets extension field types

Parameters:



72
73
74
# File 'lib/contentful/management/ui_extension.rb', line 72

def field_types=(values)
  extension['fieldTypes'] = values
end

#nameString

Returns extension name

Returns:

  • (String)

    name



54
55
56
# File 'lib/contentful/management/ui_extension.rb', line 54

def name
  extension['name']
end

#name=(value) ⇒ Object

Sets extension name

Parameters:

  • value (String)


60
61
62
# File 'lib/contentful/management/ui_extension.rb', line 60

def name=(value)
  extension['name'] = value
end

#parametersHash

Returns extensions parameters

Returns:

  • (Hash)

    parameters



108
109
110
# File 'lib/contentful/management/ui_extension.rb', line 108

def parameters
  extension['parameters']
end

#parameters=(value) ⇒ Object

Sets extension parameters

Parameters:

  • value (Hash)


114
115
116
# File 'lib/contentful/management/ui_extension.rb', line 114

def parameters=(value)
  extension['parameters'] = value
end

#saveContentful::Management::UIExtension

If an extension is a new object gets created in the Contentful, otherwise the existing extension gets updated.

Returns:

See Also:

  • https://github.com/contentful/contentful-management.rb for details.


46
47
48
49
50
# File 'lib/contentful/management/ui_extension.rb', line 46

def save
  fail 'Invalid UI extension attributes' unless self.class.valid_extension?(extension)

  update(extension: extension)
end

Returns if extension is on sidebar

Returns:

  • (Boolean)

    sidebar



96
97
98
# File 'lib/contentful/management/ui_extension.rb', line 96

def sidebar
  extension['sidebar']
end

#sidebar=(value) ⇒ Object

Sets if extension is on sidebar

Parameters:

  • value (Boolean)


102
103
104
# File 'lib/contentful/management/ui_extension.rb', line 102

def sidebar=(value)
  extension['sidebar'] = value
end

#sourceString

Returns extension source URL or data

Returns:

  • (String)

    source URL or data



78
79
80
# File 'lib/contentful/management/ui_extension.rb', line 78

def source
  extension['src'] || extension['srcdoc']
end

#source=(value) ⇒ Object

Sets extension source

Parameters:

  • value (String)

    URL or data



84
85
86
87
88
89
90
91
92
# File 'lib/contentful/management/ui_extension.rb', line 84

def source=(value)
  if value.start_with?('http')
    extension['src'] = value
    extension.delete('srcdoc')
  else
    extension['srcdoc'] = value
    extension.delete('src')
  end
end