diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-25 19:29:39 +0000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-25 19:29:39 +0000 |
commit | 0a4035b12a6c59253cb60f9e3456513c6a6a9d33 (patch) | |
tree | 513faab640a046e21c4b254b25f1bd601590ba2d /railties/lib/rails | |
parent | 2dab493867d35d27015e3ba00d20ee6d2337320e (diff) | |
download | rails-0a4035b12a6c59253cb60f9e3456513c6a6a9d33.tar.gz rails-0a4035b12a6c59253cb60f9e3456513c6a6a9d33.tar.bz2 rails-0a4035b12a6c59253cb60f9e3456513c6a6a9d33.zip |
Revert the serializers API as other alternatives are now also under discussion
Diffstat (limited to 'railties/lib/rails')
7 files changed, 1 insertions, 83 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index f1ca9080ff..27f8d13ce8 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -33,8 +33,7 @@ module Rails :stylesheets => '-y', :stylesheet_engine => '-se', :template_engine => '-e', - :test_framework => '-t', - :serializer => '-z' + :test_framework => '-t' }, :test_unit => { @@ -59,7 +58,6 @@ module Rails :performance_tool => nil, :resource_controller => :controller, :scaffold_controller => :scaffold_controller, - :serializer => false, :stylesheets => true, :stylesheet_engine => :css, :test_framework => false, diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb index 7353a67c83..03a61a035e 100644 --- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb @@ -10,7 +10,6 @@ module Rails class_option :stylesheet_engine, :desc => "Engine for Stylesheets" hook_for :scaffold_controller, :required => true - hook_for :serializer hook_for :assets do |assets| invoke assets, [controller_name] diff --git a/railties/lib/rails/generators/rails/serializer/USAGE b/railties/lib/rails/generators/rails/serializer/USAGE deleted file mode 100644 index a49f7ea1fb..0000000000 --- a/railties/lib/rails/generators/rails/serializer/USAGE +++ /dev/null @@ -1,9 +0,0 @@ -Description: - Generates a serializer for the given resource with tests. - -Example: - `rails generate serializer Account name created_at` - - For TestUnit it creates: - Serializer: app/serializers/account_serializer.rb - TestUnit: test/unit/account_serializer_test.rb diff --git a/railties/lib/rails/generators/rails/serializer/serializer_generator.rb b/railties/lib/rails/generators/rails/serializer/serializer_generator.rb deleted file mode 100644 index 2118906227..0000000000 --- a/railties/lib/rails/generators/rails/serializer/serializer_generator.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Rails - module Generators - class SerializerGenerator < NamedBase - check_class_collision :suffix => "Serializer" - - argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" - - class_option :parent, :type => :string, :desc => "The parent class for the generated serializer" - - def create_serializer_file - template 'serializer.rb', File.join('app/serializers', class_path, "#{file_name}_serializer.rb") - end - - hook_for :test_framework - - private - - def attributes_names - attributes.select { |attr| !attr.reference? }.map { |a| a.name.to_sym } - end - - def association_names - attributes.select { |attr| attr.reference? }.map { |a| a.name.to_sym } - end - - def parent_class_name - if options[:parent] - options[:parent] - elsif (n = Rails::Generators.namespace) && n.const_defined?(:ApplicationSerializer) - "ApplicationSerializer" - elsif Object.const_defined?(:ApplicationSerializer) - "ApplicationSerializer" - else - "ActiveModel::Serializer" - end - end - end - end -end diff --git a/railties/lib/rails/generators/rails/serializer/templates/serializer.rb b/railties/lib/rails/generators/rails/serializer/templates/serializer.rb deleted file mode 100644 index 30c058c7e9..0000000000 --- a/railties/lib/rails/generators/rails/serializer/templates/serializer.rb +++ /dev/null @@ -1,9 +0,0 @@ -<% module_namespacing do -%> -class <%= class_name %>Serializer < <%= parent_class_name %> -<% if attributes.any? -%> attributes <%= attributes_names.map(&:inspect).join(", ") %> -<% end -%> -<% association_names.each do |attribute| -%> - has_one :<%= attribute %> -<% end -%> -end -<% end -%>
\ No newline at end of file diff --git a/railties/lib/rails/generators/test_unit/serializer/serializer_generator.rb b/railties/lib/rails/generators/test_unit/serializer/serializer_generator.rb deleted file mode 100644 index 533c032c3b..0000000000 --- a/railties/lib/rails/generators/test_unit/serializer/serializer_generator.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'rails/generators/test_unit' - -module TestUnit - module Generators - class SerializerGenerator < Base - check_class_collision :suffix => "SerializerTest" - - def create_test_files - template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_serializer_test.rb") - end - end - end -end diff --git a/railties/lib/rails/generators/test_unit/serializer/templates/unit_test.rb b/railties/lib/rails/generators/test_unit/serializer/templates/unit_test.rb deleted file mode 100644 index 0b1bbdcaa5..0000000000 --- a/railties/lib/rails/generators/test_unit/serializer/templates/unit_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>SerializerTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end -<% end -%> |