Class: Savon::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/options.rb

Overview

Base class for GlobalOptions and LocalOptions. Stores options in a hash, dispatches setter calls by method name, raises UnknownOptionError for anything not defined on the subclass.

Direct Known Subclasses

GlobalOptions, LocalOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



12
13
14
15
# File 'lib/savon/options.rb', line 12

def initialize(options = {})
  @options = {}
  assign options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(option, _) ⇒ Object (private)

Raises:



40
41
42
# File 'lib/savon/options.rb', line 40

def method_missing(option, _)
  raise UnknownOptionError, "Unknown #{option_type} option: #{option.inspect}"
end

Instance Attribute Details

#option_typeObject (readonly)

Returns the value of attribute option_type.



17
18
19
# File 'lib/savon/options.rb', line 17

def option_type
  @option_type
end

Instance Method Details

#[](option) ⇒ Object



19
20
21
# File 'lib/savon/options.rb', line 19

def [](option)
  @options[option]
end

#[]=(option, value) ⇒ Object



23
24
25
26
# File 'lib/savon/options.rb', line 23

def []=(option, value)
  value = [value].flatten
  send(option, *value)
end

#include?(option) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/savon/options.rb', line 28

def include?(option)
  @options.key? option
end