1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Change attributes default type to array to allow order to be preserved.

This commit is contained in:
José Valim 2009-07-21 12:00:02 +02:00
parent c90419d4f4
commit 10fd021789
7 changed files with 8 additions and 7 deletions

View file

@ -3,7 +3,7 @@ require 'generators/active_record'
module ActiveRecord
module Generators
class MigrationGenerator < Base
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
def create_migration_file
set_local_assigns!

View file

@ -3,7 +3,7 @@ require 'generators/active_record'
module ActiveRecord
module Generators
class ModelGenerator < Base
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
check_class_collision

View file

@ -5,7 +5,7 @@ module Erb
class ScaffoldGenerator < Base
include Rails::Generators::ScaffoldBase
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
class_option :form, :type => :boolean
class_option :layout, :type => :boolean

View file

@ -41,7 +41,8 @@ module Rails
# Convert attributes hash into an array with GeneratedAttribute objects.
#
def parse_attributes! #:nodoc:
self.attributes = (attributes || {}).map do |name, type|
self.attributes = (attributes || []).map do |key_value|
name, type = key_value.split(':')
Rails::Generators::GeneratedAttribute.new(name, type)
end
end

View file

@ -1,7 +1,7 @@
module Rails
module Generators
class MigrationGenerator < NamedBase #metagenerator
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
hook_for :orm, :required => true
end
end

View file

@ -1,7 +1,7 @@
module Rails
module Generators
class ModelGenerator < NamedBase #metagenerator
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
hook_for :orm, :required => true
end
end

View file

@ -3,7 +3,7 @@ require 'generators/test_unit'
module TestUnit
module Generators
class ModelGenerator < Base
argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
class_option :fixture, :type => :boolean
check_class_collision :suffix => "Test"