Skip to content

Commit

Permalink
No need for extra read in fetch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Nov 8, 2012
1 parent 52af525 commit 587ea6d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/adapter/defaults.rb
Expand Up @@ -2,8 +2,11 @@ module Adapter
module Defaults
def fetch(key, value=nil)
read(key) || begin
value = block_given? ? yield(key) : value
read(key) || value
if block_given?
yield(key)
else
value
end
end
end

Expand Down

0 comments on commit 587ea6d

Please sign in to comment.