lib/httpx/session.rb in httpx-0.4.0 vs lib/httpx/session.rb in httpx-0.4.1
- old
+ new
@@ -201,18 +201,19 @@
super
klass.instance_variable_set(:@default_options, @default_options)
klass.instance_variable_set(:@plugins, @plugins.dup)
end
- def plugin(pl, *args, &block)
+ def plugin(pl, options = nil, &block)
# raise Error, "Cannot add a plugin to a frozen config" if frozen?
pl = Plugins.load_plugin(pl) if pl.is_a?(Symbol)
unless @plugins.include?(pl)
@plugins << pl
- pl.load_dependencies(self, *args, &block) if pl.respond_to?(:load_dependencies)
+ pl.load_dependencies(self, &block) if pl.respond_to?(:load_dependencies)
@default_options = @default_options.dup
- @default_options = pl.extra_options(@default_options) if pl.respond_to?(:extra_options)
+ @default_options = pl.extra_options(@default_options, &block) if pl.respond_to?(:extra_options)
+ @default_options = @default_options.merge(options) if options
include(pl::InstanceMethods) if defined?(pl::InstanceMethods)
extend(pl::ClassMethods) if defined?(pl::ClassMethods)
opts = @default_options
@@ -225,10 +226,10 @@
opts.request_body_class.__send__(:include, pl::RequestBodyMethods) if defined?(pl::RequestBodyMethods)
opts.request_body_class.extend(pl::RequestBodyClassMethods) if defined?(pl::RequestBodyClassMethods)
opts.response_body_class.__send__(:include, pl::ResponseBodyMethods) if defined?(pl::ResponseBodyMethods)
opts.response_body_class.extend(pl::ResponseBodyClassMethods) if defined?(pl::ResponseBodyClassMethods)
opts.connection_class.__send__(:include, pl::ConnectionMethods) if defined?(pl::ConnectionMethods)
- pl.configure(self, *args, &block) if pl.respond_to?(:configure)
+ pl.configure(self, &block) if pl.respond_to?(:configure)
@default_options.freeze
end
self
end