Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added more defensive way of checking the @attributes in Item#respond_to?

Closes #944
  • Loading branch information...
commit 1016449cd5bcfd52853f1728452e26962c18790e 1 parent 58ab10a
@fabn fabn authored committed
Showing with 5 additions and 1 deletion.
  1. +1 −1  lib/tire/results/item.rb
  2. +4 −0 test/unit/results_item_test.rb
View
2  lib/tire/results/item.rb
@@ -27,7 +27,7 @@ def method_missing(method_name, *arguments)
end
def respond_to?(method_name, include_private = false)
- @attributes.has_key?(method_name.to_sym) || super
+ (@attributes || {}).has_key?(method_name.to_sym) || super
end
def [](key)
View
4 test/unit/results_item_test.rb
@@ -82,6 +82,10 @@ class AlmostHash < Hash; end
assert @document.respond_to?(:title, true)
end
+ should "not raise errors when unserializing" do
+ assert_nothing_raised { YAML.load(YAML.dump(@document)) }
+ end
+
should "return nil for non-existing keys/methods" do
assert_nothing_raised { @document.whatever }
assert_nil @document.whatever
Please sign in to comment.
Something went wrong with that request. Please try again.