Add :nodoc: to ActiveModel::SecurePassword.min_cost

[ci skip]
Merge pull request #12058 from gaurish/secure-pass-doc

Add nodoc to ActiveModel::SecurePassword.min_cost
Refactoring Generators::Base.

The defaults hash isn't used unless the +class_options+ hash has a
particular key, so we don't need to compute it unless this is true.

Also moving some code for extracting a module into its own method.
Merge pull request #12061 from wangjohn/refactoring_generators_base

Refactoring Generators::Base.
only call to_a when we have to
extract owner id calculation to a method
avoid extra empty array allocation
remove extra flat_map array
no need to to_a the scope
correctly typecast keys, remove conditionals, reduce object allocations
Merge branch 'typecast'

* typecast:
  correctly typecast keys, remove conditionals, reduce object allocations
  no need to to_a the scope
  remove extra flat_map array
  avoid extra empty array allocation
  extract owner id calculation to a method
  only call to_a when we have to