Class: Smplkit::Audit::Action

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

Overview

A distinct action slug seen for the account.

Same shape as ResourceTypeid and action 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 (action, resource_type) triple, not the action overall.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#actionString

Returns The distinct action slug.

Returns:

  • (String)

    The distinct action slug.



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

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

#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.



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

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

#idString

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

Returns:

  • (String)

    JSON:API resource id (same as action).



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

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

Class Method Details

.from_resource(resource) ⇒ Object



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

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