Sha256: f6e8b2b72cbb96423ff303a6e573795253c604221d217f10800e67e8ad8a92ce

Contents?: true

Size: 1.74 KB

Versions: 45

Compression:

Stored size: 1.74 KB

Contents

<% if class_path.last.present? -%>
require_relative "../<%= class_path.last.underscore %>"

<% end -%>
<% module_namespacing do -%>
class <%= class_name %> < <%= [feature_package_name, "ResourceRecord"].join "::" %>
  # add concerns above.

<% attributes.select(&:cents?).each do |attribute| -%>
  has_cents :<%= attribute.name %>
<% end -%>
  # add model configurations above.

<% attributes.select(&:reference?).each do |attribute| -%>
  belongs_to :<%= attribute.name %><%= ", polymorphic: true" if attribute.polymorphic? %><%= ", class_name: \"#{attribute.attr_options[:class_name]}\"" if attribute.attr_options[:class_name] %>
<% end -%>
  # add belongs_to associations above.

  # add has_one associations above.

  # add has_many associations above.

<% attributes.select(&:attachment?).each do |attribute| -%>
  has_one_attached :<%= attribute.name %>
<% end -%>
<% attributes.select(&:attachments?).each do |attribute| -%>
  has_many_attached :<%= attribute.name %>
<% end -%>
  # add attachments above.

  # add scopes above.

<% attributes.select(&:required?).each do |attribute| -%>
  <%- next if attribute.reference? || attribute.rich_text? || attribute.token? || attribute.password_digest? -%>
  validates :<%= attribute.attribute_name %>, presence: true
<% end -%>
  # add validations above.

  # add callbacks above.

  # add delegations above.

<% attributes.select(&:rich_text?).each do |attribute| -%>
  has_rich_text :<%= attribute.name %>
<% end -%>
<% attributes.select(&:token?).each do |attribute| -%>
  has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
<% end -%>
<% if attributes.any?(&:password_digest?) -%>
  has_secure_password
<% end -%>
  # add misc attribute macros above.

  # add methods above.
end
<% end -%>

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
plutonium-0.19.2 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.19.1 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.19.0 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.8 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.7 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.6 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.5 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.4 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.3 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.2 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.1 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.18.0 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.16.5 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.16.4 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.16.3 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.16.1 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.16.0 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.15.24 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.15.23 lib/generators/pu/res/model/templates/model.rb.tt
plutonium-0.15.22 lib/generators/pu/res/model/templates/model.rb.tt