diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-09-24 15:46:29 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-24 21:02:30 +0200 |
commit | bac0826b1fa5f39274d61ad51304548c725a304f (patch) | |
tree | a8389dc480a95838925e51954a5e0a2dc658c54c /activerecord/lib/rails/generators/active_record/model | |
parent | e83634081a9222446df608106c8df5a6831d64db (diff) | |
download | rails-bac0826b1fa5f39274d61ad51304548c725a304f.tar.gz rails-bac0826b1fa5f39274d61ad51304548c725a304f.tar.bz2 rails-bac0826b1fa5f39274d61ad51304548c725a304f.zip |
Refactor namespaced generators to use module_namespacing block helper
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/rails/generators/active_record/model')
3 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/model_generator.rb b/activerecord/lib/rails/generators/active_record/model/model_generator.rb index bb53c489be..960c29c49c 100644 --- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb +++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb @@ -17,12 +17,12 @@ module ActiveRecord end def create_model_file - namespaced_template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") + template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") end def create_module_file return if class_path.empty? - namespaced_template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") if behavior == :invoke + template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") if behavior == :invoke end hook_for :test_framework diff --git a/activerecord/lib/rails/generators/active_record/model/templates/model.rb b/activerecord/lib/rails/generators/active_record/model/templates/model.rb index 21ae29e9f2..5c47f8b241 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/model.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/model.rb @@ -1,5 +1,7 @@ +<% module_namespacing do -%> class <%= class_name %> < <%= parent_class_name.classify %> <% attributes.select {|attr| attr.reference? }.each do |attribute| -%> belongs_to :<%= attribute.name %> <% end -%> end +<% end -%> diff --git a/activerecord/lib/rails/generators/active_record/model/templates/module.rb b/activerecord/lib/rails/generators/active_record/model/templates/module.rb index bb4220f038..fca2908080 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/module.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/module.rb @@ -1,5 +1,7 @@ +<% module_namespacing do -%> module <%= class_path.map(&:camelize).join('::') %> def self.table_name_prefix '<%= class_path.join('_') %>_' end end +<% end -%> |