Class: ReactorSDK::Resources::DataElement

Inherits:
BaseResource show all
Defined in:
lib/reactor_sdk/resources/data_element.rb

Instance Attribute Summary

Attributes inherited from BaseResource

#attributes, #id, #meta, #relationships, #type

Instance Method Summary collapse

Methods inherited from BaseResource

#==, #[], attribute, #initialize, #relationship_data, #relationship_id, #relationship_ids, #to_h

Constructor Details

This class inherits a constructor from ReactorSDK::Resources::BaseResource

Instance Method Details

#clean_textBoolean

Returns Whether to clean text values.

Returns:

  • (Boolean)

    Whether to clean text values



34
# File 'lib/reactor_sdk/resources/data_element.rb', line 34

attribute :clean_text, as: :boolean

#created_atString

Returns ISO8601 timestamp when the element was created.

Returns:

  • (String)

    ISO8601 timestamp when the element was created



57
# File 'lib/reactor_sdk/resources/data_element.rb', line 57

attribute :created_at

#default_valueString?

Returns Default value when the element returns nil.

Returns:

  • (String, nil)

    Default value when the element returns nil



40
# File 'lib/reactor_sdk/resources/data_element.rb', line 40

attribute :default_value

#delegate_descriptor_idString

Returns Identifies the extension delegate powering this element Format: “extension-package-name::data-element::element-name” Example: “core::dataElements::custom-code”.

Returns:

  • (String)

    Identifies the extension delegate powering this element Format: “extension-package-name::data-element::element-name” Example: “core::dataElements::custom-code”



49
# File 'lib/reactor_sdk/resources/data_element.rb', line 49

attribute :delegate_descriptor_id

#enabledBoolean

Returns Whether the data element is enabled.

Returns:

  • (Boolean)

    Whether the data element is enabled



31
# File 'lib/reactor_sdk/resources/data_element.rb', line 31

attribute :enabled, as: :boolean

#force_lower_caseBoolean

Returns Whether to force lowercase.

Returns:

  • (Boolean)

    Whether to force lowercase



37
# File 'lib/reactor_sdk/resources/data_element.rb', line 37

attribute :force_lower_case, as: :boolean

#inspectString

Returns Human-readable representation.

Returns:

  • (String)

    Human-readable representation



100
101
102
103
104
105
# File 'lib/reactor_sdk/resources/data_element.rb', line 100

def inspect
  '#<ReactorSDK::Resources::DataElement ' \
    "id=#{id.inspect} " \
    "name=#{name.inspect} " \
    "delegate=#{delegate_descriptor_id.inspect}>"
end

#nameString

Returns Display name of the data element.

Returns:

  • (String)

    Display name of the data element



28
# File 'lib/reactor_sdk/resources/data_element.rb', line 28

attribute :name

#parsed_settingsHash

Returns the settings field parsed into a Ruby Hash.

This is the primary accessor for data element configuration. It handles all extension types uniformly:

- Core custom code elements storing JavaScript as JSON-encoded string
- Any third-party extension settings structure

The app can render this as formatted JSON for display and diffing —exactly as Adobe Launch does in its own version comparison UI.

Behaviour by input type:

- JSON-encoded string → parsed into Hash
- Already a Hash     → returned as-is
- nil or blank       → returns empty Hash
- Unparseable string → returns empty Hash, raw value still on settings

The raw settings value is always preserved on the settings attribute unchanged — this method never modifies the underlying data.

Returns:

  • (Hash)

    Parsed settings or empty hash if nil, blank, or unparseable



87
88
89
90
91
92
93
94
95
# File 'lib/reactor_sdk/resources/data_element.rb', line 87

def parsed_settings
  raw = @attributes['settings']
  return {} if raw.nil? || raw == ''
  return raw if raw.is_a?(Hash)

  JSON.parse(raw)
rescue JSON::ParserError
  {}
end

#published_atString?

Returns ISO8601 timestamp when the element was last published.

Returns:

  • (String, nil)

    ISO8601 timestamp when the element was last published



63
# File 'lib/reactor_sdk/resources/data_element.rb', line 63

attribute :published_at

#settingsString

Returns Raw settings value exactly as returned by Adobe. May be a JSON-encoded string or a plain Hash depending on the extension. Use parsed_settings for reliable Hash access.

Returns:

  • (String)

    Raw settings value exactly as returned by Adobe. May be a JSON-encoded string or a plain Hash depending on the extension. Use parsed_settings for reliable Hash access.



54
# File 'lib/reactor_sdk/resources/data_element.rb', line 54

attribute :settings

#storage_durationString?

Returns How long to cache the value One of: “none”, “pageview”, “session”, “visitor”, or seconds as string.

Returns:

  • (String, nil)

    How long to cache the value One of: “none”, “pageview”, “session”, “visitor”, or seconds as string



44
# File 'lib/reactor_sdk/resources/data_element.rb', line 44

attribute :storage_duration

#updated_atString

Returns ISO8601 timestamp when the element was last updated.

Returns:

  • (String)

    ISO8601 timestamp when the element was last updated



60
# File 'lib/reactor_sdk/resources/data_element.rb', line 60

attribute :updated_at