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 /railties | |
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 'railties')
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 2 | ||||
-rw-r--r-- | railties/test/rack_logger_test.rb | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index ea88afe9f4..2297a31b6d 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -209,7 +209,7 @@ module Rails !options[:skip_active_record] && options[:database] == "sqlite3" end - class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out) + GemfileEntry = Struct.new(:name, :version, :comment, :options, :commented_out) do def initialize(name, version, comment, options = {}, commented_out = false) super end diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 3a48c4c496..e9088c44ce 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -13,7 +13,7 @@ # start with the tag optionally followed by a colon. Everything up to the end # of the line (or closing ERB comment tag) is considered to be their text. class SourceAnnotationExtractor - class Annotation < Struct.new(:line, :tag, :text) + Annotation = Struct.new(:line, :tag, :text) do def self.directories @@directories ||= %w(app config db lib test) + (ENV["SOURCE_ANNOTATION_DIRECTORIES"] || "").split(",") end diff --git a/railties/test/rack_logger_test.rb b/railties/test/rack_logger_test.rb index 7dd91a2465..33b4bc6a3a 100644 --- a/railties/test/rack_logger_test.rb +++ b/railties/test/rack_logger_test.rb @@ -20,7 +20,7 @@ module Rails def development?; false; end end - class Subscriber < Struct.new(:starts, :finishes) + Subscriber = Struct.new(:starts, :finishes) do def initialize(starts = [], finishes = []) super end |