class Bundler::Settings::Validator::Rule
属性
description[R]
公共类方法
new(keys, description, &validate) 点击切换源码
# File bundler/settings/validator.rb, line 9 def initialize(keys, description, &validate) @keys = keys @description = description @validate = validate end
公共实例方法
fail!(key, value, *reasons) 点击切换源码
# File 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) 点击切换源码
# File bundler/settings/validator.rb, line 36 def k(key) Bundler.settings.key_for(key) end
set(settings, key, value, *reasons) 点击切换源码
# File 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
validate!(key, value, settings) 点击切换源码
# File bundler/settings/validator.rb, line 15 def validate!(key, value, settings) instance_exec(key, value, settings, &@validate) end