From 9360b6be63b7a452535699bcf6ae853df7f5eea7 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 13 Jan 2017 15:09:56 +0900 Subject: 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 --- railties/lib/rails/generators/app_base.rb | 2 +- railties/lib/rails/source_annotation_extractor.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails') 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 -- cgit v1.2.3