Class: MultiGit::Ref::Updater Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_git/ref.rb

Overview

This class is abstract.

Updates a reference. Different subclasses use different mechanisms for locking and storing the references. Locks may be acquired in the constructor and must be released in #destroy! .

Updaters are inherently neither threadsafe nor reuseable. This should , however, not be a problem since they are not allocated by users.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ref) ⇒ Updater

Returns a new instance of Updater.

Parameters:



43
44
45
# File 'lib/multi_git/ref.rb', line 43

def initialize(ref)
  self.ref = ref
end

Instance Attribute Details

#refMultiGit::Ref

Returns:



30
31
32
# File 'lib/multi_git/ref.rb', line 30

def ref
  @ref
end

#targetMultiGit::Object, ... (readonly)

Returns:



27
28
29
# File 'lib/multi_git/ref.rb', line 27

def target
  @target
end

Instance Method Details

#destroy!Object

Release all resources used by this updater.



63
64
# File 'lib/multi_git/ref.rb', line 63

def destroy!
end

#nameString

Returns:

  • (String)


38
39
40
# File 'lib/multi_git/ref.rb', line 38

def name
  @ref.name
end

#repositoryMultiGit::Repository



33
34
35
# File 'lib/multi_git/ref.rb', line 33

def repository
  @ref.repository
end

#update(new) ⇒ MultiGit::Object, ...

This method is abstract.

Finally carry out the update.

Parameters:

Returns:



52
53
54
55
56
57
58
59
60
# File 'lib/multi_git/ref.rb', line 52

def update(new)
  nx = case new
       when Ref, nil then new
       when Object, Builder then repository.write(new)
       else raise Error::InvalidReferenceTarget, new
       end
  @target = nx
  return nx
end