Class: SDM::AccountHistory

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account: nil, activity_id: nil, deleted_at: nil, timestamp: nil) ⇒ AccountHistory

Returns a new instance of AccountHistory.



2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
# File 'lib/models/porcelain.rb', line 2133

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

Instance Attribute Details

#account ⇒ Object

The complete Account state at this time.



2124
2125
2126
# File 'lib/models/porcelain.rb', line 2124

def 
  @account
end

#activity_id ⇒ Object

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



2127
2128
2129
# File 'lib/models/porcelain.rb', line 2127

def activity_id
  @activity_id
end

#deleted_at ⇒ Object

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



2129
2130
2131
# File 'lib/models/porcelain.rb', line 2129

def deleted_at
  @deleted_at
end

#timestamp ⇒ Object

The time at which the Account state was recorded.



2131
2132
2133
# File 'lib/models/porcelain.rb', line 2131

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



2145
2146
2147
2148
2149
2150
2151
# File 'lib/models/porcelain.rb', line 2145

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