Class: AwsTestDump::DynamoTableDataRestore
- Inherits:
-
BaseDynamoProcessor
- Object
- BaseProcessor
- BaseDynamoProcessor
- AwsTestDump::DynamoTableDataRestore
- Defined in:
- lib/aws_test_dump.rb
Instance Attribute Summary
Attributes inherited from BaseDynamoProcessor
Instance Method Summary collapse
- #data ⇒ Object
- #data_dump_definition ⇒ Object
-
#initialize(dump_file) ⇒ DynamoTableDataRestore
constructor
A new instance of DynamoTableDataRestore.
- #parse_file ⇒ Object
- #run ⇒ Object
- #table_name ⇒ Object
Constructor Details
#initialize(dump_file) ⇒ DynamoTableDataRestore
Returns a new instance of DynamoTableDataRestore.
255 256 257 258 259 260 |
# File 'lib/aws_test_dump.rb', line 255 def initialize(dump_file) super dump_file @table_name = nil @data = nil @data_dump_definition = nil end |
Instance Method Details
#data ⇒ Object
290 291 292 293 |
# File 'lib/aws_test_dump.rb', line 290 def data parse_file if @data.nil? @data end |
#data_dump_definition ⇒ Object
278 279 280 281 282 283 |
# File 'lib/aws_test_dump.rb', line 278 def data_dump_definition if @data_dump_definition.nil? @data_dump_definition = DATA_DUMP_DEFINITIONS.find { |x| x[:table_name] == table_name} || {} end @data_dump_definition end |
#parse_file ⇒ Object
272 273 274 275 276 |
# File 'lib/aws_test_dump.rb', line 272 def parse_file file_contents = YAML.load(File.open(@dump_file)) @table_name = file_contents[:table_name] @data = file_contents[:data] end |
#run ⇒ Object
262 263 264 265 266 267 268 269 270 |
# File 'lib/aws_test_dump.rb', line 262 def run data.each_with_index do |item, index| if index == 0 item.merge!(data_dump_definition.fetch(:replace_first, {})) end item.merge!(data_dump_definition.fetch(:replace_these, {})) @dynamo_client.put_item({:table_name => table_name, item: item}) end end |
#table_name ⇒ Object
285 286 287 288 |
# File 'lib/aws_test_dump.rb', line 285 def table_name parse_file if @table_name.nil? @table_name end |