wmorgan/leveldb-ruby — pull request #8 by DataWraith (2011-10-16 10:31:59+00:00)
Title: LevelDB::DB.{new,create,load} should coerce the pathname argument into a string

This patch is intended to match the behavior of `File.open` in order to be less surprising. `File.open` coerces the filename argument into a string before attempting to use it. This makes it possible to use the Pathname convenience-wrapper from the standard library.

Unfortunately, I'm not quite sure how File.open does it exactly, so this patch changes the type of exception LevelDB throws, while File.open will still throw a TypeError.

Before:

```ruby
class Foo; end

LevelDB::DB.new(Foo)
# => TypeError: wrong argument type Class (expected String)

LevelDB::DB.new(Pathname.new('/tmp/foo'))
# => TypeError: wrong argument type Pathname (expected String)
```

After:

```ruby
class Foo; end

LevelDB::DB.new(Foo)
# => NoMethodError: undefined method `to_str' on Foo (Class)

LevelDB::DB.new(Pathname.new('/tmp/foo'))
# => #
```