Class: ReactorSDK::Resources::DataElement
- Inherits:
-
BaseResource
- Object
- BaseResource
- ReactorSDK::Resources::DataElement
- 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
-
#clean_text ⇒ Boolean
Whether to clean text values.
-
#created_at ⇒ String
ISO8601 timestamp when the element was created.
-
#default_value ⇒ String?
Default value when the element returns nil.
-
#delegate_descriptor_id ⇒ String
Identifies the extension delegate powering this element Format: “extension-package-name::data-element::element-name” Example: “core::dataElements::custom-code”.
-
#enabled ⇒ Boolean
Whether the data element is enabled.
-
#force_lower_case ⇒ Boolean
Whether to force lowercase.
-
#inspect ⇒ String
Human-readable representation.
-
#name ⇒ String
Display name of the data element.
-
#parsed_settings ⇒ Hash
Returns the settings field parsed into a Ruby Hash.
-
#published_at ⇒ String?
ISO8601 timestamp when the element was last published.
-
#settings ⇒ String
Raw settings value exactly as returned by Adobe.
-
#storage_duration ⇒ String?
How long to cache the value One of: “none”, “pageview”, “session”, “visitor”, or seconds as string.
-
#updated_at ⇒ String
ISO8601 timestamp when the element was last updated.
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_text ⇒ Boolean
Returns Whether to clean text values.
34 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 34 attribute :clean_text, as: :boolean |
#created_at ⇒ String
Returns ISO8601 timestamp when the element was created.
57 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 57 attribute :created_at |
#default_value ⇒ String?
Returns Default value when the element returns nil.
40 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 40 attribute :default_value |
#delegate_descriptor_id ⇒ String
Returns 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 |
#enabled ⇒ Boolean
Returns Whether the data element is enabled.
31 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 31 attribute :enabled, as: :boolean |
#force_lower_case ⇒ Boolean
Returns Whether to force lowercase.
37 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 37 attribute :force_lower_case, as: :boolean |
#inspect ⇒ String
Returns 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 |
#name ⇒ String
Returns Display name of the data element.
28 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 28 attribute :name |
#parsed_settings ⇒ Hash
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.
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_at ⇒ String?
Returns ISO8601 timestamp when the element was last published.
63 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 63 attribute :published_at |
#settings ⇒ String
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.
54 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 54 attribute :settings |
#storage_duration ⇒ String?
Returns 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_at ⇒ String
Returns ISO8601 timestamp when the element was last updated.
60 |
# File 'lib/reactor_sdk/resources/data_element.rb', line 60 attribute :updated_at |