Sha256: fd791d778799456448f8a1ed7fb9d6a6f77eba8d73fcb4f0dc93cd14f87756d2
Contents?: true
Size: 1.1 KB
Versions: 7
Compression:
Stored size: 1.1 KB
Contents
class <%= class_name %> <% max = 2 presets = {'Text' => ':lazy => false', 'String' => ':length => 500'} reserved_dm_names = DataMapper::Resource.instance_methods + DataMapper::Resource.private_instance_methods Array(attributes).each do |attribute| if reserved_dm_names.include? attribute.name raise "reserved property name '#{attribute.name}'" elsif !DdModelGenerator::VALID_TYPES.include? attribute.type.to_s.camelcase raise "unknown property type '#{attribute.type}'" end max = attribute.name.size if attribute.name.size > max end -%> include DataMapper::Resource storage_names[:default] = "<%= class_name %>" property :id,<%= " " * (max - 2) %> Serial <% Array(attributes).each do |attribute| klass = attribute.type.to_s.camelcase more = presets.has_key?(klass) ? ", #{presets[klass]}" : '' pad = max - attribute.name.size rad = 13 - klass.size %> property :<%= attribute.name %>, <%= " " * pad %><%= "#{klass}" %>, <%= " " * rad %>:required => true<%= more %> <% end -%> <% unless options[:skip_timestamps] -%> timestamps :at <% end -%> end
Version data entries
7 entries across 7 versions & 1 rubygems