Sha256: 08a7ee71801d8fc2980f08e4eb91745366427b69407e73a6f123283f61e858dc

Contents?: true

Size: 588 Bytes

Versions: 5

Compression:

Stored size: 588 Bytes

Contents

class <%= class_name %> < ActiveRecord::Base
<%- flag_attrs.each do |attr| -%>
  include DoesFlag[<%= attr.name(:symbol) %>, default: <%= attr.default %>]
<%- end -%>
<%- if defaults.any? -%>
  has_defaults(<%= defaults %>)
<%- end -%>
<%- model.attrs.select(&:assignable_values).each do |attr|  -%>
  assignable_values_for :<%= attr.name %>, <%= attr.options.slice(:allow_blank, :default) %> do
    <%= attr.assignable_values %>
  end
<%- end -%>

  def to_s
<% if model.label_attr -%>
    <%= model.label_attr.name %>.to_s
<% else -%>
    "<%= model.name %>##{id}"
<% end -%>
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
katapult-0.3.0 lib/generators/katapult/model/templates/model.rb
katapult-0.2.0 lib/generators/katapult/model/templates/model.rb
katapult-0.1.2 lib/generators/katapult/model/templates/model.rb
katapult-0.1.1 lib/generators/katapult/model/templates/model.rb
katapult-0.1.0 lib/generators/katapult/model/templates/model.rb