diff options
author | Akira Matsuda <ronnie@dio.jp> | 2017-01-13 15:09:56 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2017-01-13 15:13:47 +0900 |
commit | 9360b6be63b7a452535699bcf6ae853df7f5eea7 (patch) | |
tree | d1ad1280439883cf0fb328efe45e09dfa581182f /actionpack/test | |
parent | be5ddc250874e6c7f4d22e34791f5187448ebb0e (diff) | |
download | rails-9360b6be63b7a452535699bcf6ae853df7f5eea7.tar.gz rails-9360b6be63b7a452535699bcf6ae853df7f5eea7.tar.bz2 rails-9360b6be63b7a452535699bcf6ae853df7f5eea7.zip |
class Foo < Struct.new(:x) creates an extra unneeded anonymous class
because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/lib/controller/fake_models.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb index 046b4167bb..b768553e7a 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -1,6 +1,6 @@ require "active_model" -class Customer < Struct.new(:name, :id) +Customer = Struct.new(:name, :id) do extend ActiveModel::Naming include ActiveModel::Conversion @@ -28,7 +28,7 @@ class Customer < Struct.new(:name, :id) end end -class Post < Struct.new(:title, :author_name, :body, :secret, :persisted, :written_on, :cost) +Post = Struct.new(:title, :author_name, :body, :secret, :persisted, :written_on, :cost) do extend ActiveModel::Naming include ActiveModel::Conversion extend ActiveModel::Translation |