Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #267 from radar/master

HWIA#to_hash should convert to normal Hash objects
  • Loading branch information...
commit 6f1b6b7650842614bcc9003939a4dca8cebb8ffd 2 parents 976de90 + 5253be5
@wycats wycats authored
View
5 lib/thor/core_ext/hash_with_indifferent_access.rb
@@ -45,6 +45,11 @@ def merge!(other)
self
end
+ # Convert to a Hash with String keys.
+ def to_hash
+ Hash.new(default).merge!(self)
+ end
+
protected
def convert_key(key)
View
5 spec/core_ext/hash_with_indifferent_access_spec.rb
@@ -40,4 +40,9 @@
expect(other[:force]).to eq(false)
expect(other[:baz]).to eq("boom")
end
+
+ it "converts to a traditional hash" do
+ expect(@hash.to_hash.class).to eq(Hash)
+ expect(@hash).to eq({ 'foo' => 'bar', 'baz' => 'bee', 'force' => true })
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.