lib/httpx/options.rb in httpx-0.17.0 vs lib/httpx/options.rb in httpx-0.18.0

- old
+ new

@@ -79,30 +79,30 @@ attr_reader(optname) end def def_option(optname, *args, &block) - if args.size.zero? && !block_given? + if args.size.zero? && !block class_eval(<<-OUT, __FILE__, __LINE__ + 1) - def option_#{optname}(v); v; end + def option_#{optname}(v); v; end # def option_smth(v); v; end OUT return end deprecated_def_option(optname, *args, &block) end def deprecated_def_option(optname, layout = nil, &interpreter) warn "DEPRECATION WARNING: using `def_option(#{optname})` for setting options is deprecated. " \ - "Define module OptionsMethods and `def option_#{optname}(val)` instead." + "Define module OptionsMethods and `def option_#{optname}(val)` instead." if layout class_eval(<<-OUT, __FILE__, __LINE__ + 1) - def option_#{optname}(value) - #{layout} - end + def option_#{optname}(value) # def option_origin(v) + #{layout} # URI(v) + end # end OUT - elsif block_given? + elsif interpreter define_method(:"option_#{optname}") do |value| instance_exec(value, &interpreter) end end end