diff --git a/Gemfile.lock b/Gemfile.lock index 49e0ae7abe7..45748c6ba3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,9 +221,6 @@ GEM tzinfo event_emitter (0.2.6) eventmachine (1.2.7) - eventmachine (1.2.7-java) - eventmachine (1.2.7-x64-mingw32) - eventmachine (1.2.7-x86-mingw32) execjs (2.7.0) faraday (1.3.0) faraday-net_http (~> 1.0) @@ -291,14 +288,12 @@ GEM hiredis (0.6.3) hiredis (0.6.3-java) http_parser.rb (0.6.0) - http_parser.rb (0.6.0-java) httpclient (2.8.3) i18n (1.8.10) concurrent-ruby (~> 1.0) image_processing (1.12.1) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - jar-dependencies (0.4.1) jdbc-mysql (5.1.47) jdbc-postgres (42.2.14) jdbc-sqlite3 (3.28.0) @@ -310,7 +305,6 @@ GEM mustache nokogiri libxml-ruby (3.2.1) - libxml-ruby (3.2.1-x64-mingw32) listen (3.5.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -368,8 +362,6 @@ GEM path_expander (1.1.0) pg (1.2.3) psych (3.3.1) - psych (3.3.1-java) - jar-dependencies (>= 0.1.7) public_suffix (4.0.6) puma (5.2.2) nio4r (~> 2.0) diff --git a/actionpack/lib/abstract_controller/url_for.rb b/actionpack/lib/abstract_controller/url_for.rb index bd74c27d3b8..b6591397232 100644 --- a/actionpack/lib/abstract_controller/url_for.rb +++ b/actionpack/lib/abstract_controller/url_for.rb @@ -22,12 +22,10 @@ module AbstractController end def action_methods - @action_methods ||= begin - if _routes - super - _routes.named_routes.helper_names - else - super - end + @action_methods ||= if _routes + super - _routes.named_routes.helper_names + else + super end end end diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 0064c8d5c77..e6e37c06f5c 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -258,12 +258,10 @@ module ActionDispatch # req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080' # req.port # => 8080 def port - @port ||= begin - if raw_host_with_port =~ /:(\d+)$/ - $1.to_i - else - standard_port - end + @port ||= if raw_host_with_port =~ /:(\d+)$/ + $1.to_i + else + standard_port end end diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 2d80f912c81..4f109535be2 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -223,9 +223,7 @@ module ActiveRecord end def reflection_scope - @reflection_scope ||= begin - reflection.join_scopes(klass.arel_table, klass.predicate_builder, klass).inject(&:merge!) || klass.unscoped - end + @reflection_scope ||= reflection.join_scopes(klass.arel_table, klass.predicate_builder, klass).inject(&:merge!) || klass.unscoped end def build_scope diff --git a/activerecord/lib/active_record/encryption/encrypted_attribute_type.rb b/activerecord/lib/active_record/encryption/encrypted_attribute_type.rb index e948a190d11..9eb02c88721 100644 --- a/activerecord/lib/active_record/encryption/encrypted_attribute_type.rb +++ b/activerecord/lib/active_record/encryption/encrypted_attribute_type.rb @@ -119,9 +119,7 @@ module ActiveRecord end def clean_text_scheme - @clean_text_scheme ||= begin - ActiveRecord::Encryption::Scheme.new(downcase: downcase?, encryptor: ActiveRecord::Encryption::NullEncryptor.new) - end + @clean_text_scheme ||= ActiveRecord::Encryption::Scheme.new(downcase: downcase?, encryptor: ActiveRecord::Encryption::NullEncryptor.new) end end end diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb index 18d50d1a14c..8e0fcb99b03 100644 --- a/activerecord/lib/active_record/inheritance.rb +++ b/activerecord/lib/active_record/inheritance.rb @@ -260,19 +260,17 @@ module ActiveRecord end def set_base_class # :nodoc: - @base_class = begin - if self == Base + @base_class = if self == Base + self + else + unless self < Base + raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord" + end + + if superclass == Base || superclass.abstract_class? self else - unless self < Base - raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord" - end - - if superclass == Base || superclass.abstract_class? - self - else - superclass.base_class - end + superclass.base_class end end end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 1e4c1747759..cd11cd71d53 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -698,16 +698,14 @@ module ActiveRecord # User.where(name: 'Oscar').to_sql # # => SELECT "users".* FROM "users" WHERE "users"."name" = 'Oscar' def to_sql - @to_sql ||= begin - if eager_loading? - apply_join_dependency do |relation, join_dependency| - relation = join_dependency.apply_column_aliases(relation) - relation.to_sql - end - else - conn = klass.connection - conn.unprepared_statement { conn.to_sql(arel) } + @to_sql ||= if eager_loading? + apply_join_dependency do |relation, join_dependency| + relation = join_dependency.apply_column_aliases(relation) + relation.to_sql end + else + conn = klass.connection + conn.unprepared_statement { conn.to_sql(arel) } end end diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 4f461b9aa0f..07a680cd1c8 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -63,15 +63,11 @@ Product = Struct.new(:name) do delegate :name, to: :type, prefix: true def manufacturer - @manufacturer ||= begin - nil.unknown_method - end + @manufacturer ||= nil.unknown_method end def type - @type ||= begin - nil.type_name - end + @type ||= nil.type_name end end diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index ca37ed7dfa3..2957218d52c 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -259,8 +259,7 @@ module Rails # Stores some of the Rails initial environment parameters which # will be used by middlewares and engines to configure themselves. def env_config - @app_env_config ||= begin - super.merge( + @app_env_config ||= super.merge( "action_dispatch.parameter_filter" => config.filter_parameters, "action_dispatch.redirect_filter" => config.filter_redirect, "action_dispatch.secret_key_base" => secret_key_base, @@ -288,7 +287,6 @@ module Rails "action_dispatch.content_security_policy_nonce_directives" => config.content_security_policy_nonce_directives, "action_dispatch.permissions_policy" => config.permissions_policy, ) - end end # If you try to define a set of Rake tasks on the instance, these will get diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index 8b1874ae805..f17ae80063f 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -86,10 +86,8 @@ module Rails # # Rails::Command::TestCommand.base_name # => 'rails' def base_name - @base_name ||= begin - if base = name.to_s.split("::").first - base.underscore - end + @base_name ||= if base = name.to_s.split("::").first + base.underscore end end @@ -97,11 +95,9 @@ module Rails # # Rails::Command::TestCommand.command_name # => 'test' def command_name - @command_name ||= begin - if command = name.to_s.split("::").last - command.chomp!("Command") - command.underscore - end + @command_name ||= if command = name.to_s.split("::").last + command.chomp!("Command") + command.underscore end end diff --git a/railties/lib/rails/generators/actions/create_migration.rb b/railties/lib/rails/generators/actions/create_migration.rb index dab494ed4db..6b37a983b22 100644 --- a/railties/lib/rails/generators/actions/create_migration.rb +++ b/railties/lib/rails/generators/actions/create_migration.rb @@ -39,10 +39,8 @@ module Rails end def existing_migration - @existing_migration ||= begin - @base.class.migration_exists?(migration_dir, migration_file_name) || + @existing_migration ||= @base.class.migration_exists?(migration_dir, migration_file_name) || File.exist?(@destination) && @destination - end end alias :exists? :existing_migration diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index f0868a64bf5..46f7f20d575 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -324,21 +324,17 @@ module Rails # Sets the base_name taking into account the current class namespace. def self.base_name # :doc: - @base_name ||= begin - if base = name.to_s.split("::").first - base.underscore - end + @base_name ||= if base = name.to_s.split("::").first + base.underscore end end # Removes the namespaces and get the generator name. For example, # Rails::Generators::ModelGenerator will return "model" as generator name. def self.generator_name # :doc: - @generator_name ||= begin - if generator = name.to_s.split("::").last - generator.delete_suffix!("Generator") - generator.underscore - end + @generator_name ||= if generator = name.to_s.split("::").last + generator.delete_suffix!("Generator") + generator.underscore end end