Skip to content

Commit

Permalink
eliminate ivar uninitialized warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pjhyett committed Sep 2, 2008
1 parent 76cd39a commit a3f37a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/grit/lazy.rb
Expand Up @@ -20,8 +20,10 @@ def lazy_reader(*args)
args.each do |arg|
ivar = "@#{arg}"
define_method(arg) do
val = instance_variable_get(ivar)
return val if val
if instance_variable_defined?(ivar)
val = instance_variable_get(ivar)
return val if val
end
instance_variable_set(ivar, (@lazy_source ||= lazy_source).send(arg))
end
end
Expand Down

0 comments on commit a3f37a0

Please sign in to comment.