2 class ElementNestableContent < Content
3 self.abstract_class = true
9 return nil if self._skip_load?
12 define_method("element_items") do |element_model|
13 self.__send__ self.class.my_manifest.associations.child_element_name(element_model)
15 define_method("elements_items") do
16 self.class.child_models.map {|element_model|
17 self.element_items element_model
24 def self.permit_attributes default_permit_attributes = []
26 self.child_models.each do |element_model|
27 name = self.my_manifest.associations.child_element_name(element_model) + '_attributes'
29 child_attrs[name] = element_model.permit_attributes(default_permit_attributes)
30 attrs.push child_attrs
39 self.elements_items.each do |item|
44 def post_attributes opt = {}
45 attr = self.copy_attributes(opt)
46 associations_attr = {}
47 self.class.child_models.each do |element_model|
48 name = self.class.my_manifest.associations.child_element_name(element_model) + '_attributes'
49 if self.class.my_manifest.associations.has_one?(element_model)
50 e = self.element_items(element_model).post_attributes(opt)
53 self.element_items(element_model).each do |element|
54 e[element.post_attribute_key] = element.post_attributes(opt)
57 associations_attr[name] = e
59 attr.merge! associations_attr