Class: V::Adapters::Git::Head

Inherits:
Object
  • Object
show all
Defined in:
lib/v/adapters/git/branches.rb

Overview

The head behaves like a commit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, branch) ⇒ Head

Returns a new instance of Head.



10
11
12
13
# File 'lib/v/adapters/git/branches.rb', line 10

def initialize(env, branch)
  @environment, @branch = env, branch
  @path = File.join env.git_dir, %W[ refs heads #{ branch } ]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

Delegates to commit.



24
25
26
# File 'lib/v/adapters/git/branches.rb', line 24

def method_missing(meth, *args, &block)
  commit.send meth, *args, &block
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



8
9
10
# File 'lib/v/adapters/git/branches.rb', line 8

def branch
  @branch
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/v/adapters/git/branches.rb', line 8

def path
  @path
end

Instance Method Details

#commitObject

Returns the tip of the branch.



16
17
18
19
20
21
# File 'lib/v/adapters/git/branches.rb', line 16

def commit
  @environment.schedule do
    raise V::EUNREV unless File.readable? @path
    Commit.with @environment, :name => File.read(@path).chomp
  end
end