Skip to content

Commit

Permalink
Use a more appropriate variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim committed Aug 11, 2024
1 parent cac03a6 commit e204f8a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/loadout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ def list(*a, **k, &b) = loadout.list(*a, **k, &b)

class Config
protected attr_writer :type
protected attr_reader :lookup_stack
protected attr_reader :lookup_list

def initialize(env, creds)
@env = env
@creds = creds
@type = nil
@prefix_stack = []
@lookup_stack = Set[]
@lookup_list = Set[]
@prefix_default = NONE
end

def env(*keys, &default)
return dup.tap { _1.lookup_stack << :env } if keys.empty?
@lookup_stack << :env
return dup.tap { _1.lookup_list << :env } if keys.empty?
@lookup_list << :env
lookup(keys, &default)
end

def cred(*keys, &default)
return dup.tap { _1.lookup_stack << :cred } if keys.empty?
@lookup_stack << :cred
return dup.tap { _1.lookup_list << :cred } if keys.empty?
@lookup_list << :cred
lookup(keys, &default)
end

Expand All @@ -68,9 +68,9 @@ def list(sep = DEFAULT_LIST_SEP) = dup.tap { _1.type = [:list, sep] }

def initialize_dup(other)
@creds = other.instance_variable_get(:@creds)
@type = other.instance_variable_get(:@type).dup
@prefix_stack = other.instance_variable_get(:@prefix_stack).dup
@lookup_stack = other.instance_variable_get(:@lookup_stack).dup
@type = other.instance_variable_get(:@type).dup
@prefix_stack = other.instance_variable_get(:@prefix_stack).dup
@lookup_list = other.instance_variable_get(:@lookup_list).dup

unless other.instance_variable_get(:@prefix_default).equal?(NONE)
@prefix_default = other.instance_variable_get(:@prefix_default).dup
Expand All @@ -85,7 +85,7 @@ def lookup(keys)
value = NONE
keys = @prefix_stack.flatten + keys

@lookup_stack.each do |source|
@lookup_list.each do |source|
value =
case source
when :cred; lookup_cred(keys)
Expand All @@ -99,7 +99,7 @@ def lookup(keys)
return @prefix_default.call unless @prefix_default.equal?(NONE)
raise_missing(keys)
ensure
@lookup_stack.clear
@lookup_list.clear
end

def lookup_cred(keys)
Expand Down Expand Up @@ -139,7 +139,7 @@ def raise_missing(keys)
src = []
val = []

@lookup_stack.each do |source|
@lookup_list.each do |source|
case source
when :cred
src << "credential"
Expand Down

0 comments on commit e204f8a

Please sign in to comment.