Refactor: clean up models.

* Network::Commit
** Removing unnecessary accessors.
** Removing add_refs methods.
* Network::Graph
** Removing unnecessary accessors.
** The 3 times loop of commits don't need.
This commit is contained in:
Sato Hiroyuki 2013-03-07 17:56:01 +09:00
parent e03a018d28
commit 8c5003cf75
2 changed files with 20 additions and 27 deletions

View file

@ -4,28 +4,19 @@ module Network
class Commit
include ActionView::Helpers::TagHelper
attr_accessor :time, :spaces, :refs, :parent_spaces
attr_reader :refs
attr_accessor :time, :spaces, :parent_spaces
def initialize(commit)
@_commit = commit
def initialize(raw_commit, refs)
@commit = ::Commit.new(raw_commit)
@time = -1
@spaces = []
@parent_spaces = []
@refs = refs || []
end
def method_missing(m, *args, &block)
@_commit.send(m, *args, &block)
end
def add_refs(ref_cache, repo)
if ref_cache.empty?
repo.refs.each do |ref|
ref_cache[ref.commit.id] ||= []
ref_cache[ref.commit.id] << ref
end
end
@refs = ref_cache[@_commit.id] if ref_cache.include?(@_commit.id)
@refs ||= []
@commit.send(m, *args, &block)
end
def space