Method: Gitdb::Card#access

Defined in:
lib/gitdb/Card.rb

#access(id) ⇒ Object

[View source]

49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gitdb/Card.rb', line 49

def access id
  @id = id
  o = @repo.head.target.tree.find do |o|
    o if o[:name] == id
  end
  # 找到名片后加载名片数据, 并返回Card实例, 否则返回nil
  if o != nil
    @content = JSON.parse @repo.lookup(o[:oid]).content, { symbolize_names: true }
    @uid = @content[:owner]
    self
  else
    nil
  end
end