Class: Rugged::Repository::Attributes

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rugged/attributes.rb

Constant Summary collapse

LOAD_PRIORITIES =
{
  [:file, :index] => 0,
  [:index, :file] => 1,
  [:index] => 2,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, path, options = {}) ⇒ Attributes

Returns a new instance of Attributes.



27
28
29
30
31
# File 'lib/rugged/attributes.rb', line 27

def initialize(repository, path, options = {})
  @repository = repository
  @path = path
  @load_flags = Attributes.parse_opts(options)
end

Class Method Details

.parse_opts(opt) ⇒ Object



21
22
23
24
25
# File 'lib/rugged/attributes.rb', line 21

def self.parse_opts(opt)
  flags = LOAD_PRIORITIES[opt[:priority]] || 0
  flags |= 4 if opt[:skip_system]
  flags
end

Instance Method Details

#[](attribute) ⇒ Object



33
34
35
# File 'lib/rugged/attributes.rb', line 33

def [](attribute)
  @repository.fetch_attributes(@path, attribute, @load_flags)
end

#each(&block) ⇒ Object



41
42
43
# File 'lib/rugged/attributes.rb', line 41

def each(&block)
  to_h.each(&block)
end

#to_hObject



37
38
39
# File 'lib/rugged/attributes.rb', line 37

def to_h
  @hash ||= @repository.fetch_attributes(@path, nil, @load_flags)
end