Class: MultiGit::RuggedBackend::Config
- Inherits:
-
Object
- Object
- MultiGit::RuggedBackend::Config
- Includes:
- Config
- Defined in:
- lib/multi_git/rugged_backend/config.rb
Constant Summary
Constants included from Config
Instance Method Summary collapse
- #each_explicit_key ⇒ Object
- #get(section, subsection, key) ⇒ Object
-
#initialize(rugged_config) ⇒ Config
constructor
A new instance of Config.
Methods included from Config
#[], #default?, #each, #qualified_key, #schema, #schema_for, #section, #split_key, #to_h, #with_schema
Methods included from Utils::AbstractMethods
Constructor Details
#initialize(rugged_config) ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 15 16 |
# File 'lib/multi_git/rugged_backend/config.rb', line 9 def initialize(rugged_config) @rugged_config = rugged_config @config = Hash.new([]) rugged_config.each_pair do |qk, value| key = split_key(qk) @config.fetch(key){ @config[key] = [] } << value end end |
Instance Method Details
#each_explicit_key ⇒ Object
30 31 32 33 34 35 |
# File 'lib/multi_git/rugged_backend/config.rb', line 30 def each_explicit_key return to_enum(:each_explicit_key) unless block_given? @config.each_key do |k| yield *k end end |
#get(section, subsection, key) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/multi_git/rugged_backend/config.rb', line 18 def get(section, subsection, key) s = schema_for(section, subsection, key) v = @config[ [section, subsection,key] ] if v.size == 0 s.default elsif s.list? s.convert(v) else s.convert(v.last) end end |