diff options
Diffstat (limited to 'railties/lib/generators/active_record.rb')
-rw-r--r-- | railties/lib/generators/active_record.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/railties/lib/generators/active_record.rb b/railties/lib/generators/active_record.rb index 70f2421ac2..c7316ed38b 100644 --- a/railties/lib/generators/active_record.rb +++ b/railties/lib/generators/active_record.rb @@ -4,11 +4,10 @@ require 'active_record' module ActiveRecord module Generators - class Base < Rails::Generators::NamedBase + class Base < Rails::Generators::NamedBase #:nodoc: include Rails::Generators::Migration protected - # Implement the required interface for Rails::Generators::Migration. # def next_migration_number(dirname) #:nodoc: @@ -18,7 +17,40 @@ module ActiveRecord "%.3d" % (current_migration_number(dirname) + 1) end end + end + + class ActionORM < Rails::Generators::ActionORM #:nodoc: + def self.all(klass) + "#{klass}.all" + end + + def self.find(klass, params) + "#{klass}.find(#{params})" + end + + def self.build(klass, params=nil) + if params + "#{klass}.new(#{params})" + else + "#{klass}.new" + end + end + + def save + "#{name}.save" + end + + def update_attributes(params) + "#{name}.update_attributes(#{params})" + end + + def errors + "#{name}.errors" + end + def destroy + "#{name}.destroy" + end end end end |