Class: Mailflow::HeaderSet

Inherits:
Object
  • Object
show all
Defined in:
lib/mailflow/header_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers) ⇒ HeaderSet

Returns a new instance of HeaderSet.



5
6
7
# File 'lib/mailflow/header_set.rb', line 5

def initialize(headers)
  @headers = headers.transform_keys(&:to_s).transform_keys(&:downcase)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



17
18
19
# File 'lib/mailflow/header_set.rb', line 17

def method_missing(*args, &block)
  headers.send(*args, &block)
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/mailflow/header_set.rb', line 3

def headers
  @headers
end

Instance Method Details

#[](name) ⇒ Object



9
10
11
# File 'lib/mailflow/header_set.rb', line 9

def [](name)
  headers[name.to_s.downcase]
end

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/mailflow/header_set.rb', line 13

def has_key?(key)
  headers.has_key?(key.to_s.downcase)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/mailflow/header_set.rb', line 21

def respond_to_missing?(method_name, include_private = false)
  headers.respond_to?(method_name) || super
end