From e8d2c031ea890ce2a4126c9d9eaa9f4e6b1728c9 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Mon, 18 Oct 2021 22:13:36 -0400 Subject: [PATCH] Change strategy method implementation to return a Hash. --- lib/database_cleaner/cleaners.rb | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/database_cleaner/cleaners.rb b/lib/database_cleaner/cleaners.rb index d8d08ac..7fb5940 100644 --- a/lib/database_cleaner/cleaners.rb +++ b/lib/database_cleaner/cleaners.rb @@ -13,17 +13,23 @@ module DatabaseCleaner fetch([orm, opts]) { add_cleaner(orm, **opts) } end + # It returns a hash with all the strategies associated with + # all the cleaners. + # + # For example: + # + # ``` + # cleaners.strategy + # => { + # :active_record_1 => :truncation, + # :active_record_2 => :truncation, + # :data_mapper_1 => :truncation + # } + # ``` + # + # @return [Hash] def strategy - strategies = transform_values(&:strategy) - - case strategies.values.uniq.compact.count - when 0 - nil - when 1 - strategies.values.first - else - strategies - end + transform_values(&:strategy) end def strategy=(strategy)