Module: Rack::Client::CookieJar::Options
- Included in:
- Context
- Defined in:
- lib/rack/client/middleware/cookie_jar/options.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.option_accessor(key) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/rack/client/middleware/cookie_jar/options.rb', line 5 def self.option_accessor(key) name = option_name(key) define_method(key) { || [name] } define_method("#{key}=") { |value| [name] = value } define_method("#{key}?") { || !! [name] } end |
.option_name(key) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rack/client/middleware/cookie_jar/options.rb', line 20 def option_name(key) case key when Symbol ; "rack-client-cookiejar.#{key}" when String ; key else raise ArgumentError end end |
Instance Method Details
#initialize_options(options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rack/client/middleware/cookie_jar/options.rb', line 33 def (={}) @default_options = { 'rack-client-cookiejar.storage' => Storage.new, 'rack-client-cookiejar.cookiestore' => 'heap:/', } self. = end |
#options ⇒ Object
12 13 14 |
# File 'lib/rack/client/middleware/cookie_jar/options.rb', line 12 def @default_options.merge(@options) end |
#options=(hash = {}) ⇒ Object
16 17 18 |
# File 'lib/rack/client/middleware/cookie_jar/options.rb', line 16 def (hash = {}) @options = hash.each { |key,value| write_option(key, value) } end |