1 class Manifest.Model extends ManifestBase.Base
\r
5 @json.attributes ||= {}
\r
6 @json.associations ||= {}
\r
8 @json.attributes.id = {
\r
15 @json.attributes.created_at = {
\r
18 @json.attributes.updated_at = {
\r
24 @table_name = @json.table_name
\r
25 @attributes = ManifestBase.load_name_values this, @json, 'attributes', Manifest.ModelModule.Attribute
\r
26 @associations = ManifestBase.load_value this, @json, 'associations', Manifest.ModelModule.Association
\r
27 @list = ManifestBase.load_value this, @json, 'list', Manifest.ModelModule.List
\r
33 Manifest.item_name_to_model @name
\r
38 valid_encode_columns: () ->
\r
40 _.each @attributes, (attribute, attribute_name) ->
\r
41 next if not attribute.type == 'text'
\r
42 r.push attribute_name
\r
46 return 'author' if @attributes.author_id
\r
47 return 'artist' if @attributes.artist_id
\r
50 content_model: () ->
\r
51 return true if @owner_type
\r
54 child_model_manifests: () ->
\r
56 _.each Manifest.items, (peta_manifest, peta_name) ->
\r
57 next if not peta_manifest.is_element
\r
58 next if not peta_manifest.parent_model_name == @name
\r
59 r.push Manifest.models[peta_name]
\r
63 _.map @child_model_manifests, (child_model_manifest) ->
\r
64 child_model_manifest.classify
\r
66 child_element_names: () ->
\r
67 _.map @child_models, (child_model) ->
\r
68 @associations.child_element_name(child_model)
\r
70 child_element_name: (item_name) ->
\r
71 @associations.child_element_name(child_model_manifest)
\r
73 class Manifest.ModelModule
\r