Class: Saneitized::Hash

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/saneitized/hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}, options = {}) ⇒ Hash

Returns a new instance of Hash.



7
8
9
10
11
12
13
14
15
16
# File 'lib/saneitized/hash.rb', line 7

def initialize(hash = {}, options = {})
  @options = options
  @key_blacklist = Array(options.fetch(:key_blacklist){[]})
  new_hash = {}
  hash.each do |key, value|
    new_hash[sane_key(key)] = convert_key_value(key, value)
  end
  super(new_hash)
  self
end

Instance Method Details

#[]=(key, value) ⇒ Object



18
19
20
# File 'lib/saneitized/hash.rb', line 18

def []=(key, value)
  super key, Saneitized.convert(value, @options)
end

#merge!(*args, &block) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/saneitized/hash.rb', line 22

def merge!(*args, &block)
  raise NotImplementedError
end