Class: Changebase::Inline::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/changebase/inline/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Event

Returns a new instance of Event.



6
7
8
9
10
# File 'lib/changebase/inline/event.rb', line 6

def initialize(attrs)
  attrs.each { |k,v| self.send("#{k}=", v) }

  self.columns ||= {}
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def columns
  @columns
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def created_at
  @created_at
end

#database_idObject

Returns the value of attribute database_id.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def database_id
  @database_id
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def id
  @id
end

#schemaObject

Returns the value of attribute schema.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def schema
  @schema
end

#tableObject

Returns the value of attribute table.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def table
  @table
end

#timestampObject

Returns the value of attribute timestamp.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def timestamp
  @timestamp
end

#transaction_idObject

Returns the value of attribute transaction_id.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def transaction_id
  @transaction_id
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/changebase/inline/event.rb', line 3

def type
  @type
end

Instance Method Details

#as_jsonObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/changebase/inline/event.rb', line 12

def as_json
  {
    id:                 id,
    transaction_id:     transaction_id,
    lsn:                timestamp.utc.iso8601(3),
    type:               type,
    schema:             schema,
    table:              table,
    timestamp:          timestamp.utc.iso8601(3),
    columns:            columns.as_json
  }.compact
end