Skip to content

Commit

Permalink
Define implicit conversion for to_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jun 7, 2015
1 parent a26b643 commit e20dc47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def to_ary
[]
end

def to_hash
{}
end

def to_str
''
end
Expand Down
3 changes: 3 additions & 0 deletions spec/implicit_conversions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
it 'implicitly converts to an empty array' do
expect(null.to_ary).to eq([])
end
it 'implicitly converts to an empty hash' do
expect(null.to_hash).to eq({})
end
it 'implicitly converts to an empty string' do
expect(null.to_str).to eq('')
end
Expand Down

0 comments on commit e20dc47

Please sign in to comment.