Class: Smplkit::Audit::EventType

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

Overview

A distinct event_type slug seen for the account.

Same shape as ResourceTypeid and event_type are the same value. created_at is the earliest sighting; when the parent list call filtered by resource_type, this is the first sighting of that specific (event_type, resource_type) triple, not the event type overall.

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.



231
232
233
234
235
236
237
238
239
240
# File 'lib/smplkit/audit/models.rb', line 231

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

#event_typeString

Returns The distinct event type slug.

Returns:

  • (String)

    The distinct event type slug.



231
232
233
234
235
236
237
238
239
240
# File 'lib/smplkit/audit/models.rb', line 231

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

#idString

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

Returns:

  • (String)

    JSON:API resource id (same as event_type).



231
232
233
234
235
236
237
238
239
240
# File 'lib/smplkit/audit/models.rb', line 231

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

Class Method Details

.from_resource(resource) ⇒ Object



232
233
234
235
236
237
238
239
# File 'lib/smplkit/audit/models.rb', line 232

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