Method: ActiveOrient::Model.delete_class

Defined in:
lib/model/model.rb

.delete_class(what = :all) ⇒ Object

Deletes the database class and removes the ruby-class



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/model/model.rb', line 87

def self.delete_class what= :all
  orientdb.delete_class(  self ) if what == :all  # remove the database-class
  ## namespace is defined in config/boot
  ns =  namespace.to_s == 'Object' ? "" : namespace.to_s
  ns_found = -> ( a_class ) do
    to_compare = a_class.to_s.split(':')
    if ns == "" && to_compare.size == 1 
      true
    elsif to_compare.first == ns
      true
    else
      false
    end
  end
  self.allocated_classes.delete_if{|x,y| x == self.ref_name && ns_found[y]}  if allocated_classes.is_a?(Hash)
  namespace.send(:remove_const, naming_convention.to_sym) if namespace &.send( :const_defined?, naming_convention)
end