Sha256: 653ae1bd841b381ea34a93fc52867e631adefec16d4e4a827ea12333fda13439

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

class Core::Repositories::<%= @scope_class %>::<%= @repository_class %> < Core::Repositories::AbstractRepository
  def initialize(params:)
    @params = params
    @id     = @params.id
  end

  def call(builder: true)
<% if @resource_owner_id.present? -%>
    resource = <%= @model_class %>.find_by(id: @id, <%=@resource_owner_id%>: @params.<%=@resource_owner_id%>)
<% else -%>
    resource = <%= @model_class %>.find_by(id: @id)
<% end -%>
    return Failure '<%= @subject_class %> not found' unless resource.present?
    Success Core::Builders::<%= @subject_class %>.new(resource).build
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rider-kick-0.0.9 lib/generators/rider_kick/templates/domains/core/repositories/fetch_by_id.rb.tt
rider-kick-0.0.8 lib/generators/rider_kick/templates/domains/core/repositories/fetch_by_id.rb.tt
rider-kick-0.0.7 lib/generators/rider_kick/templates/domains/core/repositories/fetch_by_id.rb.tt
rider-kick-0.0.6 lib/generators/rider_kick/templates/domains/core/repositories/fetch_by_id.rb.tt