Sha256: f9c551495e020356bb16eaec2b00c67fc29d2c213454d8b8c764b3b1e1e06466

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

class <%= class_name %><%= " < #{options[:parent].classify}" if options[:parent] %>
<% unless options[:parent] -%>
  include Mongoid::Document
<% end -%>
<% if options[:timestamps] -%>
  include Mongoid::Timestamps
<% end -%>
<%= 'include Mongoid::Versioning' if options[:versioning] -%>
<% if options[:embedded_in] %>
  embedded_in :<%= options[:embedded_in] %>, :inverse_of => :<%= options[:singleton] ? class_name.underscore : class_name.tableize %>
<% end %>
<% if options[:referenced_in] %>
  referenced_in :<%= options[:referenced_in] %>, :inverse_of => :<%= options[:singleton] ? class_name.underscore : class_name.tableize %>
<% end %>
<% attributes.reject{|attr| attr.reference?}.each do |attribute| -%>
  field :<%= attribute.name %>, :type => <%= attribute.type_class %>
<% end -%>
<% attributes.select{|attr| attr.reference? }.each do |attribute| -%>
  embedded_in :<%= attribute.name%>, :inverse_of => :<%= class_name.tableize %>
<% end -%>
<% if references_one -%>  references_one :<%=references_one%> <% end %>
<% if references_many -%>  references_many :<%=references_many%> <% end %>
<% if embeds_one -%>  embeds_one :<%=embeds_one%> <% end %>
<% if embeds_many -%>  embeds_many :<%=embeds_many%> <% end %>

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
my_generators-0.0.4 lib/generators/my_generators/model/templates/model.rb
my_generators-0.0.3 lib/generators/my_generators/model/templates/model.rb
my_generators-0.0.2 lib/generators/my_generators/model/templates/model.rb
my_generators-0.0.1 lib/generators/my_generators/model/templates/model.rb