class Cubic::Generator::Migrations

Generates the migrations for columns and rows attached to a model.

Public Instance Methods

design(name, options) click to toggle source

Creates a hash that will be used for file generation purposes

# File lib/cubic/generators/migrations.rb, line 7
def design(name, options)
  @files << { name: "create_#{name}.rb",
              path: '/db/migrations/',
              content: "DB.create_table :#{name.to_s.concat('s')} do
                primary_key :id
                #{pair(options)}
              end" }
end

Private Instance Methods

pair(options) click to toggle source

Example: {email: :string} turns into 't.string :email'

# File lib/cubic/generators/migrations.rb, line 19
def pair(options)
  options.keys.map { |f| "#{options[f].capitalize} :#{f}" }.join("\n")
end