diff options
Diffstat (limited to 'lib/git/object.rb')
-rw-r--r-- | lib/git/object.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/git/object.rb b/lib/git/object.rb index 33c3e38..afda923 100644 --- a/lib/git/object.rb +++ b/lib/git/object.rb @@ -10,7 +10,8 @@ module Git attr_accessor :sha, :size, :type, :mode @base = nil - + @contents = nil + def initialize(base, sha) @base = base @sha = sha.to_s @@ -18,8 +19,9 @@ module Git setup end + # caches the contents of this call in memory def contents - @base.lib.object_contents(@sha) + @contents || @contents = @base.lib.object_contents(@sha) end def contents_array |