1 class Manifest.Model extends ManifestBase.Base
\r
17 @json['attributes'] ||= {}
\r
18 @json['associations'] ||= {}
\r
19 @json['list'] ||= {}
\r
20 @json['attributes']['id'] = {
\r
27 @json['attributes']['created_at'] = {
\r
30 @json['attributes']['updated_at'] = {
\r
36 _attributes = ManifestBase.load_name_values this, @json, 'attributes', Manifest.ModelModule.Attribute
\r
37 _associations = ManifestBase.load_value this, @json, 'associations', Manifest.ModelModule.Association
\r
38 _list = ManifestBase.load_value this, @json, 'list', Manifest.ModelModule.List
\r
44 Manifest.item_name_to_model _name
\r
47 @classify.table_name
\r
49 valid_encode_columns: () ->
\r
51 _.each @attributes, (attribute, attribute_name) ->
\r
52 next if not attribute.type == 'text'
\r
53 r.push attribute_name
\r
57 return 'author' if @attributes['author_id']
\r
58 return 'artist' if @attributes['artist_id']
\r
61 content_model: () ->
\r
62 return true if @owner_type
\r
65 child_model_manifests: () ->
\r
67 _.each Manifest.items, (peta_manifest, peta_name) ->
\r
68 next if not peta_manifest.is_element
\r
69 next if not peta_manifest.parent_model_name == @name
\r
70 r.push Manifest.models[peta_name]
\r
74 _.map @child_model_manifests, (child_model_manifest) ->
\r
75 child_model_manifest.classify
\r
77 child_element_names: () ->
\r
78 _.map @child_models, (child_model) ->
\r
79 _associations.child_element_name(child_model)
\r
81 child_element_name: (item_name) ->
\r
82 _associations.child_element_name(child_model_manifest)
\r
84 class Manifest.ModelModule
\r