Skip to content

Commit

Permalink
Replace map + compact with filter_map
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusRich committed Apr 23, 2021
1 parent 487ff13 commit c3d7794
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion actioncable/lib/action_cable/channel/test_case.rb
Expand Up @@ -246,7 +246,7 @@ def perform(action, data = {})
# Returns messages transmitted into channel
def transmissions
# Return only directly sent message (via #transmit)
connection.transmissions.map { |data| data["message"] }.compact
connection.transmissions.filter_map { |data| data["message"] }
end

# Enhance TestHelper assertions to handle non-String
Expand Down
2 changes: 1 addition & 1 deletion actioncable/lib/action_cable/connection/identification.rb
Expand Up @@ -26,7 +26,7 @@ def identified_by(*identifiers)
# Return a single connection identifier that combines the value of all the registered identifiers into a single gid.
def connection_identifier
unless defined? @connection_identifier
@connection_identifier = connection_gid identifiers.map { |id| instance_variable_get("@#{id}") }.compact
@connection_identifier = connection_gid identifiers.filter_map { |id| instance_variable_get("@#{id}") }
end

@connection_identifier
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/abstract_controller/caching.rb
Expand Up @@ -50,7 +50,7 @@ def view_cache_dependency(&dependency)
end

def view_cache_dependencies
self.class._view_cache_dependencies.map { |dep| instance_exec(&dep) }.compact
self.class._view_cache_dependencies.filter_map { |dep| instance_exec(&dep) }
end

private
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/rendering.rb
Expand Up @@ -26,7 +26,7 @@ def inherited(klass)

# Before processing, set the request formats in current controller formats.
def process_action(*) #:nodoc:
self.formats = request.formats.map(&:ref).compact
self.formats = request.formats.filter_map(&:ref)
super
end

Expand Down
Expand Up @@ -955,7 +955,7 @@ def convert_value_to_parameters(value)
def each_element(object, &block)
case object
when Array
object.grep(Parameters).map { |el| yield el }.compact
object.grep(Parameters).filter_map { |el| yield el }
when Parameters
if object.nested_attributes?
object.each_nested_attribute(&block)
Expand Down
2 changes: 1 addition & 1 deletion actiontext/lib/action_text/attachment.rb
Expand Up @@ -20,7 +20,7 @@ def from_node(node, attachable = nil)
end

def from_attachables(attachables)
Array(attachables).map { |attachable| from_attachable(attachable) }.compact
Array(attachables).filter_map { |attachable| from_attachable(attachable) }
end

def from_attachable(attachable, attributes = {})
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/digestor_test.rb
Expand Up @@ -363,7 +363,7 @@ def nested_dependencies(template_name)

def tree_template_formats(template_name)
tree = ActionView::Digestor.tree(template_name, finder)
tree.flatten.map(&:template).compact.map(&:format)
tree.flatten.filter_map { |node| node.template&.format }
end

def disable_resolver_caching
Expand Down
2 changes: 1 addition & 1 deletion activerecord/Rakefile
Expand Up @@ -119,7 +119,7 @@ end
n = ENV["BUILDKITE_PARALLEL_JOB"].to_i
m = ENV["BUILDKITE_PARALLEL_JOB_COUNT"].to_i

test_files = test_files.each_slice(m).map { |slice| slice[n] }.compact
test_files = test_files.each_slice(m).filter_map { |slice| slice[n] }
end

test_files.each do |file|
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/nested_attributes.rb
Expand Up @@ -486,7 +486,7 @@ def assign_nested_attributes_for_collection_association(association_name, attrib
existing_records = if association.loaded?
association.target
else
attribute_ids = attributes_collection.map { |a| a["id"] || a[:id] }.compact
attribute_ids = attributes_collection.filter_map { |a| a["id"] || a[:id] }
attribute_ids.empty? ? [] : association.scope.where(association.klass.primary_key => attribute_ids)
end

Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/arel/select_manager.rb
Expand Up @@ -96,7 +96,7 @@ def from(table)
end

def froms
@ast.cores.map { |x| x.from }.compact
@ast.cores.filter_map { |x| x.from }
end

def join(relation, klass = Nodes::InnerJoin)
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/commands/dbconsole/dbconsole_command.rb
Expand Up @@ -31,7 +31,7 @@ def start
sslcapath: "--ssl-capath",
sslcipher: "--ssl-cipher",
sslkey: "--ssl-key"
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
}.filter_map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }

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

0 comments on commit c3d7794

Please sign in to comment.