Class: V::Adapters::Git::Head
- Inherits:
-
Object
- Object
- V::Adapters::Git::Head
- Defined in:
- lib/v/adapters/git/branches.rb
Overview
The head behaves like a commit.
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#commit ⇒ Object
Returns the tip of the branch.
-
#initialize(env, branch) ⇒ Head
constructor
A new instance of Head.
-
#method_missing(meth, *args, &block) ⇒ Object
Delegates to commit.
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
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
8 9 10 |
# File 'lib/v/adapters/git/branches.rb', line 8 def branch @branch end |
#path ⇒ Object (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
#commit ⇒ Object
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 |