Class: Github::BranchCache

Inherits:
Object
  • Object
show all
Includes:
Mem
Defined in:
lib/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ BranchCache

Returns a new instance of BranchCache.



70
71
72
73
# File 'lib/github.rb', line 70

def initialize(repo)
  @repo = repo
  @cache = {}
end

Instance Method Details

#create(name, sha) ⇒ Object



75
76
77
# File 'lib/github.rb', line 75

def create(name, sha)
  @cache[name] = client.create_ref(@repo, "heads/#{name}", sha)
end

#delete(name) ⇒ Object



87
88
89
90
91
# File 'lib/github.rb', line 87

def delete(name)
  ref = client.delete_ref(@repo, "heads/#{name}")
  @cache.delete(name)
  ref
end

#read(name) ⇒ Object



79
80
81
# File 'lib/github.rb', line 79

def read(name)
  @cache[name] = client.ref(@repo, "heads/#{name}")
end

#update(name, sha) ⇒ Object



83
84
85
# File 'lib/github.rb', line 83

def update(name, sha)
  @cache[name] = client.update_branch(@repo, name, sha)
end