Class: Igniter::LedgerClient::Results::ChangeEventResult

Inherits:
Object
  • Object
show all
Includes:
HashAccess
Defined in:
lib/igniter/ledger_client/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashAccess

#[]

Constructor Details

#initialize(raw = {}) ⇒ ChangeEventResult

Returns a new instance of ChangeEventResult.



321
322
323
324
325
326
327
328
329
330
331
# File 'lib/igniter/ledger_client/results.rb', line 321

def initialize(raw = {})
  @raw = raw
  data = normalize(raw)
  @cursor = normalize_cursor(data[:cursor])
  @sequence = (data[:sequence] || cursor[:sequence])&.to_i
  @store = token(data[:store])
  @key = data[:key]
  @fact_id = data[:fact_id]
  @value_hash = data[:value_hash] || fact_value_hash(raw)
  freeze
end

Instance Attribute Details

#cursorObject (readonly)

Returns the value of attribute cursor.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def cursor
  @cursor
end

#fact_idObject (readonly)

Returns the value of attribute fact_id.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def fact_id
  @fact_id
end

#keyObject (readonly)

Returns the value of attribute key.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def key
  @key
end

#rawObject (readonly)

Returns the value of attribute raw.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def raw
  @raw
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def sequence
  @sequence
end

#storeObject (readonly)

Returns the value of attribute store.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def store
  @store
end

#value_hashObject (readonly)

Returns the value of attribute value_hash.



319
320
321
# File 'lib/igniter/ledger_client/results.rb', line 319

def value_hash
  @value_hash
end

Instance Method Details

#to_hObject



333
334
335
336
337
338
339
340
341
342
343
# File 'lib/igniter/ledger_client/results.rb', line 333

def to_h
  {
    sequence: sequence,
    store: store,
    key: key,
    fact_id: fact_id,
    value_hash: value_hash,
    cursor: cursor,
    raw: raw
  }.compact
end