Class: Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/universum/type.rb

Class Method Summary collapse

Class Method Details

.of(*args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/universum/type.rb', line 24

def self.of( *args )
   ## e.g. gets passed in [{Address=>Integer}]

   ##  check for Integer - use Hash.new(0)

   ##  check for Bool    - use Hash.new(False)

   if args[0].is_a? Hash
     arg = args[0].to_a   ## convert to array (for easier access)

     klass_key   = arg[0][0]
     klass_value = arg[0][1]
     klass = SafeHash.build_class( klass_key, klass_value )
     klass.new
   else
     ## todo/fix: throw argument error/exception

     Hash.new    ## that is, "plain" {} with all "standard" defaults

   end
end