Class: SDM::Activity

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

An Activity is a record of an action taken against a strongDM deployment, e.g. a user creation, resource deletion, sso configuration change, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor: nil, completed_at: nil, description: nil, entities: nil, id: nil, ip_address: nil, verb: nil) ⇒ Activity

Returns a new instance of Activity.



1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
# File 'lib/models/porcelain.rb', line 1232

def initialize(
  actor: nil,
  completed_at: nil,
  description: nil,
  entities: nil,
  id: nil,
  ip_address: nil,
  verb: nil
)
  @actor = actor == nil ? nil : actor
  @completed_at = completed_at == nil ? nil : completed_at
  @description = description == nil ? "" : description
  @entities = entities == nil ? [] : entities
  @id = id == nil ? "" : id
  @ip_address = ip_address == nil ? "" : ip_address
  @verb = verb == nil ? "" : verb
end

Instance Attribute Details

#actorObject

The account who executed this activity. If the actor later has a name or email change, that change is not reflected here. Actor is a snapshot of the executing account at the time an activity took place.



1216
1217
1218
# File 'lib/models/porcelain.rb', line 1216

def actor
  @actor
end

#completed_atObject

The time this activity took effect.



1218
1219
1220
# File 'lib/models/porcelain.rb', line 1218

def completed_at
  @completed_at
end

#descriptionObject

A humanized description of the activity.



1220
1221
1222
# File 'lib/models/porcelain.rb', line 1220

def description
  @description
end

#entitiesObject

The entities involved in this activity. These entities can be any first class entity in the strongDM system, eg. a user, a role, a node, an account grant. Not every activity affects explicit entities.



1224
1225
1226
# File 'lib/models/porcelain.rb', line 1224

def entities
  @entities
end

#idObject

Unique identifier of the Activity.



1226
1227
1228
# File 'lib/models/porcelain.rb', line 1226

def id
  @id
end

#ip_addressObject

The IP from which this action was taken.



1228
1229
1230
# File 'lib/models/porcelain.rb', line 1228

def ip_address
  @ip_address
end

#verbObject

The kind of activity which has taken place.



1230
1231
1232
# File 'lib/models/porcelain.rb', line 1230

def verb
  @verb
end

Instance Method Details

#to_json(options = {}) ⇒ Object



1250
1251
1252
1253
1254
1255
1256
# File 'lib/models/porcelain.rb', line 1250

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end