Changeset 3469
- Timestamp:
- 01/23/06 06:40:43 (4 years ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/object_and_class.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/proc.rb (added)
- trunk/activesupport/test/core_ext/object_and_class_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/proc_test.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r3468 r3469 1 1 *SVN* 2 3 * Add Object#instance_exec, like instance_eval but passes its arguments to the block. (Active Support will not override the Ruby 1.9 implementation of this method.) [Sam Stephenson] 4 5 * Add Proc#bind(object) for changing a proc or block's self by returning a Method bound to the given object. Based on why the lucky stiff's "cloaker" method. [Sam Stephenson] 2 6 3 7 * Fix merge and dup for hashes with indifferent access #3404 [kenneth.miller@bitfield.net] trunk/activesupport/lib/active_support/core_ext/object_and_class.rb
r3356 r3469 66 66 ActiveSupport::JSON.encode(self) 67 67 end 68 69 unless defined? instance_exec # 1.9 70 def instance_exec(*arguments, &block) 71 block.bind(self)[*arguments] 72 end 73 end 68 74 end 69 75 trunk/activesupport/test/core_ext/object_and_class_ext_test.rb
r3356 r3469 112 112 assert_equal({'a' => 1, 'b' => 2}, object.instance_values) 113 113 end 114 115 def test_instance_exec_passes_arguments_to_block 116 block = Proc.new { |value| [self, value] } 117 assert_equal %w(hello goodbye), 'hello'.instance_exec('goodbye', &block) 118 end 119 114 120 end