aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/lib/controller/fake_models.rb
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2017-01-13 15:09:56 +0900
committerAkira Matsuda <ronnie@dio.jp>2017-01-13 15:13:47 +0900
commit9360b6be63b7a452535699bcf6ae853df7f5eea7 (patch)
treed1ad1280439883cf0fb328efe45e09dfa581182f /actionview/test/lib/controller/fake_models.rb
parentbe5ddc250874e6c7f4d22e34791f5187448ebb0e (diff)
downloadrails-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 'actionview/test/lib/controller/fake_models.rb')
-rw-r--r--actionview/test/lib/controller/fake_models.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/actionview/test/lib/controller/fake_models.rb b/actionview/test/lib/controller/fake_models.rb
index ddc915895d..8db52ccbe1 100644
--- a/actionview/test/lib/controller/fake_models.rb
+++ b/actionview/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
@@ -31,7 +31,7 @@ end
class GoodCustomer < Customer
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
@@ -163,7 +163,7 @@ module Blog
true
end
- class Post < Struct.new(:title, :id)
+ Post = Struct.new(:title, :id) do
extend ActiveModel::Naming
include ActiveModel::Conversion
@@ -183,8 +183,7 @@ class ArelLike
end
end
-class Car < Struct.new(:color)
-end
+Car = Struct.new(:color)
class Plane
attr_reader :to_key