Class: Bundler::Settings::Validator::Rule
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/bundler/settings/validator.rb |
Class Method Summary
- .new(keys, description, &validate) ⇒ Rule constructor
Instance Attribute Summary
- #description readonly
Instance Method Summary
Constructor Details
.new(keys, description, &validate) ⇒ Rule
# File 'lib/bundler/settings/validator.rb', line 9
def initialize(keys, description, &validate) @keys = keys @description = description @validate = validate end
Instance Attribute Details
#description (readonly)
[ GitHub ]# File 'lib/bundler/settings/validator.rb', line 7
attr_reader :description
Instance Method Details
#fail!(key, value, *reasons)
# File 'lib/bundler/settings/validator.rb', line 19
def fail!(key, value, *reasons) reasons.unshift @description raise InvalidOption, "Setting `#{key}` to #{value.inspect} failed:\n#{reasons.map {|r| " - #{r}" }.join("\n")}" end
#k(key)
[ GitHub ]#set(settings, key, value, *reasons)
[ GitHub ]# File 'lib/bundler/settings/validator.rb', line 24
def set(settings, key, value, *reasons) hash_key = k(key) return if settings[hash_key] == value reasons.unshift @description Bundler.ui.info "Setting `#{key}` to #{value.inspect}, since #{reasons.join(", ")}" if value.nil? settings.delete(hash_key) else settings[hash_key] = value end end