Module: HTTPX::Plugins::Cookies::InstanceMethods

Extended by:
Forwardable
Defined in:
lib/httpx/plugins/cookies.rb

Instance Method Summary collapse

Instance Method Details

#initialize(options = {}, &blk) ⇒ Object



73
74
75
# File 'lib/httpx/plugins/cookies.rb', line 73

def initialize(options = {}, &blk)
  super({ cookies: Store.new }.merge(options), &blk)
end

#with_cookies(cookies) ⇒ Object



77
78
79
# File 'lib/httpx/plugins/cookies.rb', line 77

def with_cookies(cookies)
  branch(default_options.with_cookies(cookies))
end

#wrapObject



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/httpx/plugins/cookies.rb', line 81

def wrap
  return super unless block_given?

  super do |session|
    old_cookies_store = @options.cookies.dup
    begin
      yield session
    ensure
      @options = @options.with_cookies(old_cookies_store)
    end
  end
end