lib/faraday/options.rb in faraday-0.9.0.rc6 vs lib/faraday/options.rb in faraday-0.9.0.rc7

- old
+ new

@@ -6,13 +6,13 @@ def self.from(value) value ? new.update(value) : new end # Public - def each(&block) + def each members.each do |key| - block.call key.to_sym, send(key) + yield(key.to_sym, send(key)) end end # Public def update(obj) @@ -46,23 +46,21 @@ dup.update(value) end # Public def fetch(key, *args) - return send(key) if symbolized_key_set.include?(key.to_sym) - - key_setter = "#{key}=" - - if args.size > 0 - return send(key_setter, args.first) + unless symbolized_key_set.include?(key.to_sym) + key_setter = "#{key}=" + if args.size > 0 + send(key_setter, args.first) + elsif block_given? + send(key_setter, Proc.new.call(key)) + else + raise self.class.fetch_error_class, "key not found: #{key.inspect}" + end end - - if block_given? - return send(key_setter, Proc.new.call(key)) - end - - raise self.class.fetch_error_class, "key not found: #{key.inspect}" + send(key) end # Public def values_at(*keys) keys.map { |key| send(key) } @@ -178,11 +176,13 @@ extend Forwardable def_delegators :uri, :scheme, :scheme=, :host, :host=, :port, :port=, :path, :path= def self.from(value) case value - when String then value = {:uri => Utils.URI(value)} - when URI then value = {:uri => value} + when String + value = {:uri => Utils.URI(value)} + when URI + value = {:uri => value} when Hash, Options if uri = value.delete(:uri) value[:uri] = Utils.URI(uri) end end