62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/metarecord/generators/crails/destroy_generator.rb', line 62
def generate_for object
reset
CrailsDestroyGenerator.my_prepare if CrailsDestroyGenerator.destroy_data.nil?
@finalclass = object[:classname]
@klassname = get_classname(object)
_append "void #{@klassname}::on_dependent_destroy(#{id_type} self_id)"
_append "{"
unless object[:classname].nil?
@indent += 1
depended_by = CrailsDestroyGenerator.destroy_data[object[:classname]]
if depended_by.class == Array
_append "#{GeneratorBase.odb_connection[:object]} database;"
depended_by.each do |relation|
_append "// #{relation[:class]}"
_append "{"
@indent += 1
if relation[:type] == "has_one"
one_to_many relation
elsif relation[:type] == "has_many"
many_to_many relation
end
@indent -= 1
_append "}\n"
end
end
@indent -= 1
end
_append "}"
@src
end
|