5 def self.set_default my_manifest
6 my_manifest.each {|item_name, model_manifest|
7 model_manifest['attributes'] ||= {}
8 model_manifest['associations'] ||= {}
9 model_manifest|['attributes'].each {|attribute_name, attribute_manifest|
10 attribute_manifest.each {|attribute_name, attribute_manifest|
11 raise "undefined type for models > #{item_name} > attributes > #{attribute_name}\n" unless attribute_manifest['type']
12 attribute_manifest['primary_key'] ||= 0
13 attribute_manifest['rules'] ||= {}
14 attribute_manifest['rules'].each {|rule_name, rule_manifest|
19 model_manifest|['associations'].each {|association_name, association_manifest|
20 association_manifest['belongs_to'] ||= {}
21 association_manifest['has_many'] ||= {}
22 association_manifest['has_one'] ||= {}
23 association_manifest['belongs_to'].each {|belongs_to_name, belongs_to_manifest|
24 belongs_to_manifest['id_column'] ||= belongs_to_name + '_id'
26 association_manifest['has_many'].each {|has_many_name, has_many_manifest|
27 raise "undefined foreign_key for models > #{item_name} > associations > has_many > #{has_many_name}\n" unless has_many_manifest['foreign_key']
28 has_many_manifest['model'] ||= has_many_name.singularize
31 association_manifest['belongs_to'].each {|belongs_to_name, belongs_to_manifest|
32 belongs_to_manifest['id_column'] ||= belongs_to_name + '_id'
38 def initialize model_manifest
39 @model_manifest = model_manifest
40 @item_name = @model_manifest.item_name
41 @manifest = @model_manifest.manifest
42 @model_conf = @model_manifest.conf
45 def open list_name, page, page_size, operators