1 class Manifest.Model extends ManifestBase.Base
\r
5 @json.attributes ||= {}
\r
6 @json.associations ||= {}
\r
7 @json.table_name ||= Manifest.manifest().pluralize(@name)
\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
32 Manifest.item_name_to_model @name
\r
34 valid_encode_columns: () ->
\r
36 _.each @attributes, (attribute, attribute_name) ->
\r
37 next if not attribute.type == 'text'
\r
38 r.push attribute_name
\r
42 return 'author' if @attributes.author_id
\r
43 return 'artist' if @attributes.artist_id
\r
46 content_model: () ->
\r
47 return true if @owner_type
\r
50 child_model_manifests: () ->
\r
52 _.each Manifest.manifest().items, (peta_manifest, peta_name) =>
\r
53 return if not peta_manifest.is_element()
\r
54 return if peta_manifest.parent_item_name != @name
\r
55 r.push Manifest.manifest().models[peta_name]
\r
59 _.map @child_model_manifests(), (child_model_manifest) ->
\r
60 child_model_manifest.classify()
\r
62 child_element_names: () ->
\r
63 _.map @child_models(), (child_model) ->
\r
64 @associations.child_element_name(child_model)
\r
66 child_element_name: (item_name) ->
\r
67 @associations.child_element_name(@child_model_manifest())
\r
69 class Manifest.ModelModule
\r