Class: Unity::DynamoDBStreams::EventParser
- Inherits:
-
Object
- Object
- Unity::DynamoDBStreams::EventParser
- Defined in:
- lib/unity/dynamodbstreams/event_parser.rb,
lib/unity/dynamodbstreams/event_parser/version.rb
Defined Under Namespace
Classes: EventStruct, StreamRecordStruct
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Method Summary collapse
- #call(hash) ⇒ Object
-
#initialize ⇒ EventParser
constructor
A new instance of EventParser.
Constructor Details
#initialize ⇒ EventParser
Returns a new instance of EventParser.
24 25 26 |
# File 'lib/unity/dynamodbstreams/event_parser.rb', line 24 def initialize @deserializer = Unity::DynamoDB::AttributeDeserializer.new end |
Instance Method Details
#call(hash) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/unity/dynamodbstreams/event_parser.rb', line 28 def call(hash) EventStruct.new( hash['eventID'], hash['eventName'], hash['eventVersion'], hash['eventSource'], hash['eventSourceARN'], hash['awsRegion'], StreamRecordStruct.new( hash['dynamodb']['ApproximateCreationDateTime'], @deserializer.call(hash['dynamodb']['Keys']), @deserializer.call(hash['dynamodb']['NewImage']), @deserializer.call(hash['dynamodb']['OldImage']), hash['dynamodb']['SequenceNumber'], hash['dynamodb']['SizeBytes'], hash['dynamodb']['StreamViewType'] ), hash['userIdentity'] ) end |