1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/soap/property.rb: passing block by reference.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nahi 2003-12-22 04:41:35 +00:00
parent a7b3a42850
commit b1d80f310f
2 changed files with 12 additions and 12 deletions

View file

@ -1,3 +1,7 @@
Mon Dec 22 13:40:19 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/soap/property.rb: passing block by reference.
Mon Dec 22 00:32:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/syck/emitter.c (syck_emitter_write): str bigger than

View file

@ -35,15 +35,11 @@ class Property
include Enumerable
def self.load(stream)
prop = new
prop.load(stream)
prop
new.load(stream)
end
def self.open(filename)
File.open(filename) do |f|
load(f)
end
File.open(filename) { |f| load(f) }
end
# find property from $:.
@ -117,9 +113,9 @@ class Property
# hook: block which will be called with 2 args, name and value
def add_hook(name = nil, &hook)
if name.nil?
assign_self_hook(hook)
assign_self_hook(&hook)
else
assign_hook(name_to_a(name), hook)
assign_hook(name_to_a(name), &hook)
end
end
@ -200,7 +196,7 @@ protected
@self_hook + (@hook[key] || NO_HOOK)
end
def local_assign_hook(key, hook)
def local_assign_hook(key, &hook)
check_lock(key)
@store[key] ||= nil
(@hook[key] ||= []) << hook
@ -229,13 +225,13 @@ private
hook + ref.local_hook(last_key)
end
def assign_hook(ary, hook)
def assign_hook(ary, &hook)
ary[0..-2].inject(self) { |ref, name|
ref.deref_key(to_key(name))
}.local_assign_hook(to_key(ary.last), hook)
}.local_assign_hook(to_key(ary.last), &hook)
end
def assign_self_hook(hook)
def assign_self_hook(&hook)
check_lock(nil)
@self_hook << hook
end