mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Change strategy method implementation to return a Hash.
This commit is contained in:
parent
933df38680
commit
e8d2c031ea
1 changed files with 16 additions and 10 deletions
|
@ -13,17 +13,23 @@ module DatabaseCleaner
|
||||||
fetch([orm, opts]) { add_cleaner(orm, **opts) }
|
fetch([orm, opts]) { add_cleaner(orm, **opts) }
|
||||||
end
|
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
|
def strategy
|
||||||
strategies = transform_values(&:strategy)
|
transform_values(&:strategy)
|
||||||
|
|
||||||
case strategies.values.uniq.compact.count
|
|
||||||
when 0
|
|
||||||
nil
|
|
||||||
when 1
|
|
||||||
strategies.values.first
|
|
||||||
else
|
|
||||||
strategies
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def strategy=(strategy)
|
def strategy=(strategy)
|
||||||
|
|
Loading…
Reference in a new issue