Method: ClassUtils#create_class
- Defined in:
- lib/class_utils.rb
#create_class(*class_names, properties: nil, &b) ⇒ Object
create a single class and provide properties as well
ORD.create_class( the_class_name as String or Symbol (nessesary) ,
properties: a Hash with property- and Index-descriptions (optional)) do { superclass: The name of the superclass as String or Symbol , abstract: true|false } end
or
ORD.create_class( class1, class2 ... ) { Superclass }
ORD.create_class( class ) { {superclass: the_superclass_name, abstract: true_or_false } }
ORD.create_class class
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/class_utils.rb', line 100 def create_class( *class_names, properties: nil, &b ) if block_given? the_block = yield superclass, abstract = if the_block.is_a? Class [ the_block, nil ] elsif the_block.is_a?(String) || the_block.is_a?(Symbol) [ ActiveOrient.database_classes[the_block] , nil ] elsif the_block.is_a?(Hash) [ ActiveOrient.database_classes[the_block[:superclass]], ActiveOrient.database_classes[the_block[:abstract]] ] end end superclass = superclass.presence || ActiveOrient::Model r= class_names.map do | the_class_name | the_class_name = superclass.namespace_prefix + the_class_name.to_s ## lookup the database_classes-Hash if ActiveOrient.database_classes[the_class_name].is_a?(Class) ActiveOrient.database_classes[the_class_name] else if superclass =="" || superclass.ref_name == "" create_this_class the_class_name else create_this_class( the_class_name ) do if the_block.is_a?(Hash) the_block[:superclass] = superclass.ref_name the_block else { superclass: superclass.ref_name } end end end database_classes # update_class_array create_properties( the_name , properties ) if properties.present? allocate_class_in_ruby( the_class_name ) do |that_class| keep_the_dataset = true end end end r.size==1 ? r.pop : r # return a single class or an array of created classes end |