Skip to content

Commit c3d7794

Browse files
committed
Replace map + compact with filter_map
1 parent 487ff13 commit c3d7794

File tree

11 files changed

+11
-11
lines changed

11 files changed

+11
-11
lines changed

actioncable/lib/action_cable/channel/test_case.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def perform(action, data = {})
246246
# Returns messages transmitted into channel
247247
def transmissions
248248
# Return only directly sent message (via #transmit)
249-
connection.transmissions.map { |data| data["message"] }.compact
249+
connection.transmissions.filter_map { |data| data["message"] }
250250
end
251251

252252
# Enhance TestHelper assertions to handle non-String

actioncable/lib/action_cable/connection/identification.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def identified_by(*identifiers)
2626
# Return a single connection identifier that combines the value of all the registered identifiers into a single gid.
2727
def connection_identifier
2828
unless defined? @connection_identifier
29-
@connection_identifier = connection_gid identifiers.map { |id| instance_variable_get("@#{id}") }.compact
29+
@connection_identifier = connection_gid identifiers.filter_map { |id| instance_variable_get("@#{id}") }
3030
end
3131

3232
@connection_identifier

actionpack/lib/abstract_controller/caching.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def view_cache_dependency(&dependency)
5050
end
5151

5252
def view_cache_dependencies
53-
self.class._view_cache_dependencies.map { |dep| instance_exec(&dep) }.compact
53+
self.class._view_cache_dependencies.filter_map { |dep| instance_exec(&dep) }
5454
end
5555

5656
private

actionpack/lib/action_controller/metal/rendering.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def inherited(klass)
2626

2727
# Before processing, set the request formats in current controller formats.
2828
def process_action(*) #:nodoc:
29-
self.formats = request.formats.map(&:ref).compact
29+
self.formats = request.formats.filter_map(&:ref)
3030
super
3131
end
3232

actionpack/lib/action_controller/metal/strong_parameters.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def convert_value_to_parameters(value)
955955
def each_element(object, &block)
956956
case object
957957
when Array
958-
object.grep(Parameters).map { |el| yield el }.compact
958+
object.grep(Parameters).filter_map { |el| yield el }
959959
when Parameters
960960
if object.nested_attributes?
961961
object.each_nested_attribute(&block)

actiontext/lib/action_text/attachment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def from_node(node, attachable = nil)
2020
end
2121

2222
def from_attachables(attachables)
23-
Array(attachables).map { |attachable| from_attachable(attachable) }.compact
23+
Array(attachables).filter_map { |attachable| from_attachable(attachable) }
2424
end
2525

2626
def from_attachable(attachable, attributes = {})

actionview/test/template/digestor_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def nested_dependencies(template_name)
363363

364364
def tree_template_formats(template_name)
365365
tree = ActionView::Digestor.tree(template_name, finder)
366-
tree.flatten.map(&:template).compact.map(&:format)
366+
tree.flatten.filter_map { |node| node.template&.format }
367367
end
368368

369369
def disable_resolver_caching

activerecord/Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ end
119119
n = ENV["BUILDKITE_PARALLEL_JOB"].to_i
120120
m = ENV["BUILDKITE_PARALLEL_JOB_COUNT"].to_i
121121

122-
test_files = test_files.each_slice(m).map { |slice| slice[n] }.compact
122+
test_files = test_files.each_slice(m).filter_map { |slice| slice[n] }
123123
end
124124

125125
test_files.each do |file|

activerecord/lib/active_record/nested_attributes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def assign_nested_attributes_for_collection_association(association_name, attrib
486486
existing_records = if association.loaded?
487487
association.target
488488
else
489-
attribute_ids = attributes_collection.map { |a| a["id"] || a[:id] }.compact
489+
attribute_ids = attributes_collection.filter_map { |a| a["id"] || a[:id] }
490490
attribute_ids.empty? ? [] : association.scope.where(association.klass.primary_key => attribute_ids)
491491
end
492492

activerecord/lib/arel/select_manager.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def from(table)
9696
end
9797

9898
def froms
99-
@ast.cores.map { |x| x.from }.compact
99+
@ast.cores.filter_map { |x| x.from }
100100
end
101101

102102
def join(relation, klass = Nodes::InnerJoin)

railties/lib/rails/commands/dbconsole/dbconsole_command.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def start
3131
sslcapath: "--ssl-capath",
3232
sslcipher: "--ssl-cipher",
3333
sslkey: "--ssl-key"
34-
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
34+
}.filter_map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }
3535

3636
if config[:password] && @options[:include_password]
3737
args << "--password=#{config[:password]}"

0 commit comments

Comments
 (0)