class Stax::Generators::DynamoGenerator
Attributes
attributes[RW]
hash[RW]
id[RW]
range[RW]
stack[RW]
table[RW]
Private Class Methods
Public Instance Methods
add_to_staxfile()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 37 def add_to_staxfile append_to_file 'Staxfile', "stack :#{@stack}, include: %w[DynamoDB]\n" end
append_include_template()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 41 def append_include_template file = File.join('cf', "#{stack}.rb") create_file file, "description 'Dynamo tables'\n" unless File.exists?(file) append_to_file file, "include_template '#{stack}/dyn_#{table}.rb'\n" end
ask_for_attributes()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 22 def ask_for_attributes @attributes = [] loop do name = ask('attribute name (blank when done)?') break if name.empty? type = ask('attribute type?', default: 'S') @attributes << [name, type] end end
ask_for_key_schema()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 32 def ask_for_key_schema @hash = ask('hash key?', default: attributes[0].first) @range = ask('range key?', default: attributes[1].first) end
ask_for_options()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 18 def ask_for_options @stack = options[:stack] || ask('stack to use or create', default: 'dynamo') end
check_args()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 12 def check_args usage! unless args.size == 1 @table = args.first @id = "Dyn#{table.capitalize}" end
create_table_template()
click to toggle source
# File lib/generators/dynamo/dynamo_generator.rb, line 47 def create_table_template template('dyn.rb.tt', File.join('cf', stack, "dyn_#{table}.rb")) end