hashid-rails
hashid-rails copied to clipboard
Avoid Clobbering the Config's Pepper Value
The original code was always overriding the "pepper" value with table_name
, so it didn't matter what you set that value to in the config.
The config's "pepper" value should be respected.
I didn't quite think this through, I'll throw up proper solution (that doesn't fail all the tests) quite soon.
The config now supports setting the pepper as a Proc
and evaluating it on the class. Plus now all the tests pass! :stuck_out_tongue:.
This has the advantage that you can now both disable your pepper, and make your pepper much more complex. i.e.
# Call a custom "pepper" method defined on the class
Hashid::Rails.configure do |config|
config.pepper = ->(klass) { klass.pepper }
end
# Disable pepper altogether.
Hashid::Rails.configure do |config|
config.pepper = nil
end
Can this be merged? :-)