Class: CleanHash::Safe

Inherits:
Indifferent show all
Defined in:
lib/clean-hash/types/safe_type.rb

Instance Method Summary collapse

Methods inherited from Indifferent

#[], #delete, #each, #initialize, #key?, #keys, #method_missing, #to_ary, #to_h, #to_json, #values

Constructor Details

This class inherits a constructor from CleanHash::Indifferent

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CleanHash::Indifferent

Instance Method Details

#[]=(key, value) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/clean-hash/types/safe_type.rb', line 3

def []= key, value
  value = value.to_s if value.is_a?(Symbol)

  unless value.nil? || value.is_a?(Hash) || value.is_a?(Numeric) || value.is_a?(String)
    raise ArgumentError.new('Unsupported safe type: %s' % value.class)
  end

  super
end