提交 d96e38be 编写于 作者: J Jeremy Kemper

Backport Object#instance_variable_defined? for Ruby < 1.8.6.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7649 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 7974f475
*SVN*
* Backport Object#instance_variable_defined? for Ruby < 1.8.6. [Jeremy Kemper]
* BufferedLogger#add doesn't modify the message argument. #9702 [eigentone]
* Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [DHH]
......
class Object
# Available in 1.8.6 and later.
unless respond_to?(:instance_variable_defined?)
def instance_variable_defined?(variable)
instance_variables.include?(variable.to_s)
end
end
end
......@@ -177,6 +177,13 @@ def setup
@source.instance_variable_set(:@baz, 'baz')
end
def test_instance_variable_defined
assert @source.instance_variable_defined?('@bar')
assert @source.instance_variable_defined?(:@bar)
assert !@source.instance_variable_defined?(:@foo)
assert !@source.instance_variable_defined?('@foo')
end
def test_copy_instance_variables_from_without_explicit_excludes
assert_equal [], @dest.instance_variables
@dest.copy_instance_variables_from(@source)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册