Class: CrailsDestroyPreparator
Instance Attribute Summary collapse
Instance Method Summary
collapse
#_append, _use_by_files, _use_by_models, #get_classname, #get_pluralized_name, #get_singular_name, #get_type, #get_value, #id_type, #indent, is_file_based?, #make_block, #null_id, #order_by, prepare, #property, #ptr_type, #reset, #resource_name, #should_generate_for, #should_generate_from_manifest, #should_skip_on_client?, sourcefile_to_destfile, #unindent, use, #visibility
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
6
7
8
|
# File 'lib/metarecord/generators/crails/destroy_generator.rb', line 6
def data
@data
end
|
Instance Method Details
#has_many(type, name, options = {}) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/metarecord/generators/crails/destroy_generator.rb', line 16
def has_many type, name, options = {}
unless options[:dependent].nil?
@data[type] ||= []
@data[type] << ({
type: "has_many", class: @model[:classname],
field: name, options: options
})
end
end
|
#has_one(type, name, options = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/metarecord/generators/crails/destroy_generator.rb', line 26
def has_one type, name, options = {}
unless options[:dependent].nil?
@data[type] ||= []
@data[type] << ({
type: "has_one", class: @model[:classname],
field: name, options: options
})
end
end
|
#prepare ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/metarecord/generators/crails/destroy_generator.rb', line 8
def prepare
@data = {}
Model.list.each do |model|
@model = model
self.instance_eval &model[:block]
end
end
|