Sha256: f0ce7feb1dacf9561872aaeb79bf4d844b5df14dd8138ed482e8047028f3d950
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
module DataMapper module Model # module Json def to_json_schema(repository_name = default_repository_name) to_json_schema_hash(repository_name).to_json end #TODO: Add various options in. def to_json_schema_hash(repository_name = default_repository_name) schema_hash = { 'id' => self.storage_name(repository_name), 'prototype' => Hash.new, 'properties' => Hash.new } # Handle properties properties.select { |prop| prop.field != 'id' }.each do |prop| schema_hash['properties'][prop.field] = prop.to_json_schema_hash(repository_name) end # Handle relationships relationships.each_pair do |nom,relation| next if self.name.downcase == nom schema_hash['properties'][nom] = relation.to_json_schema_hash end return schema_hash end end end
Version data entries
9 entries across 9 versions & 1 rubygems