lib/dyna/dsl/converter.rb in dyna-0.1.7 vs lib/dyna/dsl/converter.rb in dyna-0.1.8
- old
+ new
@@ -30,10 +30,11 @@
end
def output_table(name, table)
local_secondary_indexes = ''
global_secondary_indexes = ''
+ stream_specification = ''
if table[:local_secondary_indexes]
local_secondary_indexes_tmpl = <<-EOS.chomp
<% table[:local_secondary_indexes].each do |index| %>
local_secondary_index <%= index[:index_name].inspect %> do
key_schema hash: <%= index[:key_schema][0][:attribute_name].inspect %>, range: <%= index[:key_schema][1][:attribute_name].inspect %><% if index[:projection] %>
@@ -64,10 +65,22 @@
attribute_type: <%= attr[:attribute_type].inspect %>,
)
<% end %>
EOS
attribute_definitions = ERB.new(attribute_definitions_tmpl).result(binding)
+
+ if table[:stream_specification]
+ stream_specification_tmpl = <<-EOS.chomp
+
+ stream_specification(
+ stream_enabled: <%= table[:stream_specification][:stream_enabled] %>,
+ stream_view_type: <%= table[:stream_specification][:stream_view_type].inspect %>,
+ )
+EOS
+ stream_specification = ERB.new(stream_specification_tmpl).result(binding)
+ end
+
<<-EOS
table "#{name}" do
key_schema(
hash: #{table[:key_schema][0][:attribute_name].inspect},
range: #{table[:key_schema].size == 1 ? 'nil' : table[:key_schema][1][:attribute_name].inspect},
@@ -75,10 +88,10 @@
#{attribute_definitions}
provisioned_throughput(
read_capacity_units: #{table[:provisioned_throughput][:read_capacity_units]},
write_capacity_units: #{table[:provisioned_throughput][:write_capacity_units]},
)
-#{local_secondary_indexes}#{global_secondary_indexes}
+#{local_secondary_indexes}#{global_secondary_indexes}#{stream_specification}
end
EOS
end
end
end