Class: Kentico::Kontent::Delivery::ContentType

Inherits:
Object
  • Object
show all
Defined in:
lib/delivery/models/content_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ ContentType

Constructor.

  • Args:

    • source (JSON) The response from a REST request for content types



35
36
37
# File 'lib/delivery/models/content_type.rb', line 35

def initialize(source)
  @source = source
end

Instance Method Details

#elementsObject

Parses the ‘elements’ JSON object as a dynamic OpenStruct object.

  • Returns:

    • OpenStruct The elements of the content type



11
12
13
14
15
16
17
# File 'lib/delivery/models/content_type.rb', line 11

def elements
  @elements unless @elements.nil?
  @elements = JSON.parse(
    JSON.generate(@source['elements']),
    object_class: OpenStruct
  )
end

#systemObject

Parses the ‘system’ JSON object as a dynamic OpenStruct object.

  • Returns:

    • OpenStruct The system properties of the content type



23
24
25
26
27
28
29
# File 'lib/delivery/models/content_type.rb', line 23

def system
  @system unless @system.nil?
  @system = JSON.parse(
    JSON.generate(@source['system']),
    object_class: OpenStruct
  )
end