class AwsRecord::Generators::Base

def parse_gsis!

def parse_gsis!
  @gsis = (options['gsi'] || []).map do |raw_idx|
    idx = SecondaryIndex.parse(raw_idx)
    attributes = self.attributes.select { |attr| attr.name == idx.hash_key }
    if attributes.empty?
      @parse_errors << ArgumentError.new("Could not find attribute #{idx.hash_key} for gsi #{idx.name} hkey")
      next
    end
    if idx.range_key
      attributes = self.attributes.select { |attr| attr.name == idx.range_key }
      if attributes.empty?
        @parse_errors << ArgumentError.new("Could not find attribute #{idx.range_key} for gsi #{idx.name} rkey")
        next
      end
    end
    idx
  rescue ArgumentError => e
    @parse_errors << e
    next
  end
  @gsis = @gsis.compact
end