Class: Saneitized::Hash
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Saneitized::Hash
- Defined in:
- lib/saneitized/hash.rb
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
-
#initialize(hash = {}, options = {}) ⇒ Hash
constructor
A new instance of Hash.
- #merge!(*args, &block) ⇒ Object
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 = @key_blacklist = Array(.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
22 23 24 |
# File 'lib/saneitized/hash.rb', line 22 def merge!(*args, &block) raise NotImplementedError end |