Class: Smplkit::Audit::ResourceType

Inherits:
Struct
  • Object
show all
Defined in:
lib/smplkit/audit/models.rb

Overview

A distinct resource_type slug seen for the account.

The id and resource_type are the same value — JSON:API surfaces the customer-facing key as the resource id (ADR-014). The duplication keeps SDK consumers from having to dig into the id field when filtering UI controls; pick whichever name reads better in context.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#created_atString

Returns ISO-8601 timestamp of the earliest sighting for this slug.

Returns:

  • (String)

    ISO-8601 timestamp of the earliest sighting for this slug.



207
208
209
210
211
212
213
214
215
216
# File 'lib/smplkit/audit/models.rb', line 207

ResourceType = Struct.new(:id, :resource_type, :created_at, keyword_init: true) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      resource_type: attrs.resource_type || resource.id,
      created_at: attrs.created_at
    )
  end
end

#idString

Returns JSON:API resource id (same as resource_type).

Returns:

  • (String)

    JSON:API resource id (same as resource_type).



207
208
209
210
211
212
213
214
215
216
# File 'lib/smplkit/audit/models.rb', line 207

ResourceType = Struct.new(:id, :resource_type, :created_at, keyword_init: true) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      resource_type: attrs.resource_type || resource.id,
      created_at: attrs.created_at
    )
  end
end

#resource_typeString

Returns The distinct resource_type slug.

Returns:

  • (String)

    The distinct resource_type slug.



207
208
209
210
211
212
213
214
215
216
# File 'lib/smplkit/audit/models.rb', line 207

ResourceType = Struct.new(:id, :resource_type, :created_at, keyword_init: true) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      resource_type: attrs.resource_type || resource.id,
      created_at: attrs.created_at
    )
  end
end

Class Method Details

.from_resource(resource) ⇒ Object



208
209
210
211
212
213
214
215
# File 'lib/smplkit/audit/models.rb', line 208

def self.from_resource(resource)
  attrs = resource.attributes
  new(
    id: resource.id,
    resource_type: attrs.resource_type || resource.id,
    created_at: attrs.created_at
  )
end