Class: Aws::DynamoDBStreams::EventParser
- Inherits:
-
Object
- Object
- Aws::DynamoDBStreams::EventParser
- Defined in:
- lib/aws/dynamodbstreams/event_parser.rb
Defined Under Namespace
Classes: EventStruct, StreamRecordStruct
Instance Method Summary collapse
- #from(hash) ⇒ Object
-
#initialize ⇒ EventParser
constructor
A new instance of EventParser.
- #parse(json) ⇒ Object
Constructor Details
#initialize ⇒ EventParser
Returns a new instance of EventParser.
23 24 25 |
# File 'lib/aws/dynamodbstreams/event_parser.rb', line 23 def initialize @deserializer = Aws::DynamoDB::AttributeDeserializer.new end |
Instance Method Details
#from(hash) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/aws/dynamodbstreams/event_parser.rb', line 27 def from(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 |
#parse(json) ⇒ Object
48 49 50 51 |
# File 'lib/aws/dynamodbstreams/event_parser.rb', line 48 def parse(json) data = JSON.parse(json) from(data) end |