Class: Apache::Table

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/apache/fakerequest.rb

Overview

Simulate Apache::Table

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Table

Returns a new instance of Table.



166
167
168
169
# File 'lib/apache/fakerequest.rb', line 166

def initialize( hash={} )
	hash.each {|k,v| hash[k.downcase] = v}
	@hash = hash
end

Instance Method Details

#[](key) ⇒ Object Also known as: get



173
174
175
# File 'lib/apache/fakerequest.rb', line 173

def []( key )
	@hash[ key.downcase ]
end

#[]=(key, val) ⇒ Object Also known as: set



178
179
180
# File 'lib/apache/fakerequest.rb', line 178

def []=( key, val )
	@hash[ key.downcase ] = val
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


183
184
185
# File 'lib/apache/fakerequest.rb', line 183

def key?( key )
	@hash.key?( key.downcase )
end

#merge(key, val) ⇒ Object



187
188
189
190
191
# File 'lib/apache/fakerequest.rb', line 187

def merge( key, val )
	key = key.downcase
	@hash[key] = [@hash[key]] unless @hash[key].is_a?( Array )
	@hash[key] << val
end