Module: Ethon::Multi::Options
- Included in:
- Ethon::Multi
- Defined in:
- lib/ethon/multi/options.rb
Overview
This module contains the logic and knowledge about the available options on multi.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#set_options ⇒ Object
Set specified options on multi handle.
-
#value_for(option) ⇒ Object
Return the value to set to multi handle.
Class Method Details
.included(base) ⇒ Object
:nodoc:
9 10 11 12 13 14 15 16 |
# File 'lib/ethon/multi/options.rb', line 9 def self.included(base) base.extend ClassMethods base.const_set(:AVAILABLE_OPTIONS, [ :socketfunction, :socketdata, :pipelining, :timerfunction, :timerdata, :maxconnects ]) base.send(:attr_accessor, *Ethon::Multi::AVAILABLE_OPTIONS) end |
Instance Method Details
#set_options ⇒ Object
Set specified options on multi handle.
59 60 61 62 63 |
# File 'lib/ethon/multi/options.rb', line 59 def self.class..each do |option| Curl.set_option(option, value_for(option), handle, :multi) end end |
#value_for(option) ⇒ Object
Return the value to set to multi handle. It is converted with the help of bool_options, enum_options and int_options.
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ethon/multi/options.rb', line 72 def value_for(option) value = method(option).call return nil if value.nil? if self.class..include?(option) value ? 1 : 0 elsif self.class..include?(option) value.to_i else value end end |