This shadowing breaks the ability to use Faker::Types as a hash key. While not something you would normally use a hash key, loggers and memory profilers are two use cases where this problem could creep in. This issue bit us in our rspec tests and was not a fun one to track down.
Object.hash:
"Generates a Fixnum hash value for this object. This function must have the property that a.eql?(b) implies a.hash == b.hash.
The hash value is used along with eql? by the Hash class to determine if two objects reference the same hash key. Any hash value that exceeds the capacity of a Fixnum will be truncated before being used." -https://ruby-doc.org/core-2.2.0/Object.html#method-i-hash
my_hash = {}
=> {}
hash[Object] = true
=> true
hash[Bignum] = true
=> true
hash[Faker::Types] = true
=> TypeError: no implicit conversion of String into Integer
because of this, the padrino framework fails to boot
I see two possible fixes, which I don't mind implementing:
hash method on Faker::Types to something like rb_hash (doing the same for other methods, such as array, for consistency)require faker/all for this, and then require faker/cat for a specific faker, which automatically gets the necessary base classes (Config and Base, I guess).Since the first implementation (changing method names) was already merged, I guess we could close this issue, @vbrazo, @mkeiser82 ?
Most helpful comment
because of this, the padrino framework fails to boot