OSDN Git Service

fix foreign_filter list includes
[pettanr/pettanr.git] / lib / peta / element_nestable_content.rb
1 module Peta
2   class ElementNestableContent < Content
3     self.abstract_class = true
4     
5     # Dynamic Methods
6     
7     def self.load_manifest
8       super
9       # Class Methods
10       # Instance Methods
11       define_method("element_items") do |element_model|
12         self.__send__ self.class.my_manifest.associations.child_element_name(element_model)
13       end
14       define_method("elements_items") do 
15         self.class.element_models.map {|element_model|
16           self.element_items element_model
17         }.flatten
18       end
19     end
20     
21     # Class Methods
22     
23     # Instance Methods
24     def post_attributes opt = {}
25       attr = self.copy_attributes
26       hash = {}
27       self.class.element_models.each do |element_model|
28         name = self.class.my_manifest.associations.child_element_name(element_model) + '_attributes'
29         hash[name] ||= {}
30         self.element_items(element_model).each do |element|
31           hash[name][element.post_attribute_key] = element.post_attributes opt
32         end
33       end
34       attr.merge hash
35     end
36     
37   end
38 end
39