Class: Gin::StrictHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/gin/strict_hash.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



3
4
5
# File 'lib/gin/strict_hash.rb', line 3

def [] key
  super key.to_s
end

#[]=(key, value) ⇒ Object



7
8
9
# File 'lib/gin/strict_hash.rb', line 7

def []= key, value
  super key.to_s, value
end

#delete(key) ⇒ Object



11
12
13
# File 'lib/gin/strict_hash.rb', line 11

def delete key
  super key.to_s
end

#has_key?(key) ⇒ Boolean Also known as: key?

Returns:

  • (Boolean)


15
16
17
# File 'lib/gin/strict_hash.rb', line 15

def has_key? key
  super key.to_s
end

#merge(hash) ⇒ Object



21
22
23
24
25
26
# File 'lib/gin/strict_hash.rb', line 21

def merge hash
  return super if hash.class == self.class
  new_hash = self.dup
  new_hash.merge!(hash)
  new_hash
end

#merge!(hash) ⇒ Object



28
29
30
31
32
# File 'lib/gin/strict_hash.rb', line 28

def merge! hash
  return super if hash.class == self.class
  hash.each{|k,v| self[k] = v}
  self
end