Class: SDM::ResourceHistory

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

Overview

ResourceHistory records the state of a Resource at a given point in time, where every change (create, update and delete) to a Resource produces an ResourceHistory record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(activity_id: nil, deleted_at: nil, resource: nil, timestamp: nil) ⇒ ResourceHistory

Returns a new instance of ResourceHistory.



9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
# File 'lib/models/porcelain.rb', line 9468

def initialize(
  activity_id: nil,
  deleted_at: nil,
  resource: nil,
  timestamp: nil
)
  @activity_id = activity_id == nil ? "" : activity_id
  @deleted_at = deleted_at == nil ? nil : deleted_at
  @resource = resource == nil ? nil : resource
  @timestamp = timestamp == nil ? nil : timestamp
end

Instance Attribute Details

#activity_idObject

The unique identifier of the Activity that produced this change to the Resource. May be empty for some system-initiated updates.



9460
9461
9462
# File 'lib/models/porcelain.rb', line 9460

def activity_id
  @activity_id
end

#deleted_atObject

If this Resource was deleted, the time it was deleted.



9462
9463
9464
# File 'lib/models/porcelain.rb', line 9462

def deleted_at
  @deleted_at
end

#resourceObject

The complete Resource state at this time.



9464
9465
9466
# File 'lib/models/porcelain.rb', line 9464

def resource
  @resource
end

#timestampObject

The time at which the Resource state was recorded.



9466
9467
9468
# File 'lib/models/porcelain.rb', line 9466

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



9480
9481
9482
9483
9484
9485
9486
# File 'lib/models/porcelain.rb', line 9480

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