Sha256: 7531a70900c7a381b20d9b5f470575a7cf58db34028ea52a46478e189ad4394d
Contents?: true
Size: 835 Bytes
Versions: 4
Compression:
Stored size: 835 Bytes
Contents
# frozen_string_literal: true class Core::Repositories::<%= @scope_class %>::<%= @repository_class %> < Core::Repositories::AbstractRepository def initialize(id:, params: {}) @id = id @params = prepare! params, sanitize: true end def call(builder: true) resource = <%= @model_class %>.find_by(id: @id) return Failure '<%= @subject_class %> not found' unless resource.present? <% if @uploaders.present? -%> # Remove the existing images if a new one is being uploaded <% @uploaders.each do |uplaoder| -%> resource.<%=uplaoder %>.purge if @params.<%=uplaoder %>.present? && resource.<%=uplaoder %>.attached? <% end -%> <% end -%> unless resource.update(@params.to_h) return Failure build_errors(resource) end Success Core::Builders::<%= @subject_class %>.new(resource).build end end
Version data entries
4 entries across 4 versions & 1 rubygems