diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-22 04:41:35 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-22 04:41:35 +0000 |
commit | b1d80f310f090aab0c8b8500dadd715ec65851aa (patch) | |
tree | 8a782b9d519448060004156c73f9a431a6981d8e /lib | |
parent | a7b3a428501a855e3caee42474121fe8f387daf5 (diff) | |
download | ruby-b1d80f310f090aab0c8b8500dadd715ec65851aa.tar.gz |
* 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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/soap/property.rb | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/soap/property.rb b/lib/soap/property.rb index e0516aa419..079c294a77 100644 --- a/lib/soap/property.rb +++ b/lib/soap/property.rb @@ -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 |