Skip to content

Commit

Permalink
Memoize without duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Olle Jonsson committed Apr 27, 2016
1 parent 85b4177 commit 196a23a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/serverspec/type/docker_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ def [](key)
end

def inspection
return @inspection if @inspection
@inspection = ::MultiJson.load(get_inspection.stdout)[0]
@inspection ||= ::MultiJson.load(get_inspection.stdout)[0]
end

private
def get_inspection
return @get_inspection if @get_inspection
@get_inspection = @runner.run_command("docker inspect #{@name}")
@get_inspection ||= @runner.run_command("docker inspect #{@name}")
end
end
end

0 comments on commit 196a23a

Please sign in to comment.