Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/representable/hash/binding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def self.build_for(definition)
end

def read(hash, as)
return FragmentNotFound unless hash
hash.has_key?(as) ? hash[as] : FragmentNotFound
end

Expand Down
3 changes: 3 additions & 0 deletions test/hash_bindings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class SongWithRepresenter < ::Song
assert_equal Representable::Binding::FragmentNotFound, @property.read({}, "song")
end

it "will not fail if given an empty hash value and will return FRAGMENT_NOT_FOUND" do
assert_equal Representable::Binding::FragmentNotFound, @property.read(nil, "song")
end
end
end

Expand Down