decorators & tree model

This commit is contained in:
Dmitriy Zaporozhets 2011-11-20 22:32:12 +02:00
parent 6721ef01f4
commit 4bf4efe712
12 changed files with 120 additions and 29 deletions

2
app/models/commit.rb Normal file
View file

@ -0,0 +1,2 @@
class Commit
end

24
app/models/tree.rb Normal file
View file

@ -0,0 +1,24 @@
class Tree
attr_accessor :path, :tree, :project, :ref
delegate :contents,
:basename,
:name,
:data,
:text?,
:colorize,
:to => :tree
def initialize(raw_tree, project, ref = nil, path = nil)
@project, @ref, @path = project, ref, path,
@tree = if path
raw_tree / path
else
raw_tree
end
end
def is_blob?
tree.is_a?(Grit::Blob)
end
end