Class: Basis::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/basis/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(my, overrides) ⇒ Context

Returns a new instance of Context.



5
6
7
8
9
# File 'lib/basis/context.rb', line 5

def initialize my, overrides
  @git       = Hash[`git config -lz`.split("\000").map { |e| e.split "\n" }]
  @my        = my
  @overrides = overrides || {}
end

Instance Attribute Details

#myObject (readonly)

Returns the value of attribute my.



3
4
5
# File 'lib/basis/context.rb', line 3

def my
  @my
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
# File 'lib/basis/context.rb', line 11

def [] key
  @overrides[key] || @my.to_h[key] || @git[key]
end

#git(key) ⇒ Object



15
16
17
# File 'lib/basis/context.rb', line 15

def git key
  @git[key]
end