Class: Smplkit::Audit::Category

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

Overview

A distinct category value seen for the account.

Same shape as ResourceType/EventTypeid and category are the same value (JSON:API surfaces the customer-facing key as the resource id, ADR-014). created_at is the earliest sighting of this category for the account.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#categoryString

Returns The distinct category value.

Returns:

  • (String)

    The distinct category value.



284
285
286
287
288
289
290
291
292
293
# File 'lib/smplkit/audit/models.rb', line 284

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

#created_atString

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

Returns:

  • (String)

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



284
285
286
287
288
289
290
291
292
293
# File 'lib/smplkit/audit/models.rb', line 284

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

#idString

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

Returns:

  • (String)

    JSON:API resource id (same as category).



284
285
286
287
288
289
290
291
292
293
# File 'lib/smplkit/audit/models.rb', line 284

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

Class Method Details

.from_resource(resource) ⇒ Object



285
286
287
288
289
290
291
292
# File 'lib/smplkit/audit/models.rb', line 285

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