Skip to content

Commit

Permalink
Cleanup AR component.
Browse files Browse the repository at this point in the history
  • Loading branch information
DAddYE committed Aug 20, 2012
1 parent 78a9b9b commit 39edad4
Showing 1 changed file with 10 additions and 7 deletions.
Expand Up @@ -148,7 +148,7 @@ def self.down
end end
MIGRATION MIGRATION


AR_MODEL_UP_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(AR_MODEL_UP_MG) AR_MODEL_UP_MG = (<<-MIGRATION) unless defined?(AR_MODEL_UP_MG)
create_table :!TABLE! do |t| create_table :!TABLE! do |t|
!FIELDS! !FIELDS!
t.timestamps t.timestamps
Expand All @@ -161,9 +161,11 @@ def self.down


def create_model_migration(migration_name, name, columns) def create_model_migration(migration_name, name, columns)
output_model_migration(migration_name, name, columns, output_model_migration(migration_name, name, columns,
:base => AR_MIGRATION, :base => AR_MIGRATION,
:column_format => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" }, :column_format => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
:up => AR_MODEL_UP_MG, :down => AR_MODEL_DOWN_MG) :up => AR_MODEL_UP_MG,
:down => AR_MODEL_DOWN_MG
)
end end


AR_CHANGE_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(AR_CHANGE_MG) AR_CHANGE_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(AR_CHANGE_MG)
Expand All @@ -174,8 +176,9 @@ def create_model_migration(migration_name, name, columns)


def create_migration_file(migration_name, name, columns) def create_migration_file(migration_name, name, columns)
output_migration_file(migration_name, name, columns, output_migration_file(migration_name, name, columns,
:base => AR_MIGRATION, :change_format => AR_CHANGE_MG, :base => AR_MIGRATION,
:add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" }, :change_format => AR_CHANGE_MG,
:remove => Proc.new { |field, kind| "t.remove :#{field}" } :add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
:remove => Proc.new { |field, kind| "t.remove :#{field}" }
) )
end end

0 comments on commit 39edad4

Please sign in to comment.