Sha256: 03f5c657d0170303539b2e62271e748d2009c59ee519ca42ed3fc230a5e1993b

Contents?: true

Size: 802 Bytes

Versions: 5

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

class Core::Builders::<%=  @subject_class %> < RiderKick::Builders::AbstractActiveRecordEntityBuilder
  acts_as_builder_for_entity Core::Entities::<%= @subject_class%>

<% if @uploaders.present? -%>
  def attributes_for_entity
    {
<% @uploaders.each_with_index do |field, index| -%>
<% if is_singular?(field) -%>
      <%= field %>: (Rails.application.routes.url_helpers.polymorphic_url(params.<%= field %>) rescue '')<%= ',' if index < @uploaders.size - 1 %>
<% else -%>
      <%= field %>: build_assets(params.<%= field %>)<%= ',' if index < @uploaders.size - 1 %>
<% end -%>
<% end -%>
    }
  end

private

  def build_assets(assets)
    assets.to_a.map { |asset| Rails.application.routes.url_helpers.polymorphic_url(asset) rescue '' }.compact
  end
<% end -%>
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rider-kick-0.0.10 lib/generators/rider_kick/templates/domains/core/builders/builder.rb.tt
rider-kick-0.0.9 lib/generators/rider_kick/templates/domains/core/builders/builder.rb.tt
rider-kick-0.0.8 lib/generators/rider_kick/templates/domains/core/builders/builder.rb.tt
rider-kick-0.0.7 lib/generators/rider_kick/templates/domains/core/builders/builder.rb.tt
rider-kick-0.0.6 lib/generators/rider_kick/templates/domains/core/builders/builder.rb.tt