Sha256: 1daa1762c4db4ea9f3fb89ffca3ea7ead0289cceaadea1ee8c96c4ebcbfdd237

Contents?: true

Size: 487 Bytes

Versions: 95

Compression:

Stored size: 487 Bytes

Contents

# frozen_string_literal: true

module Renalware
  module Snippets
    class SnippetQuery
      attr_reader :author, :relation

      def initialize(relation: nil, author:)
        @relation ||= Snippet.includes(:author).all
        @author = author
      end

      def call
        snippets
      end

      private

      def snippets
        if author.present?
          relation.where(author_id: author.id)
        else
          relation.all
        end
      end
    end
  end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
renalware-core-2.0.111 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.110 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.109 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.108 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.106 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.105 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.104 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.103 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.102 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.101 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.100 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.99 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.98 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.97 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.96 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.95 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.94 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.93 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.92 app/models/renalware/snippets/snippet_query.rb
renalware-core-2.0.91 app/models/renalware/snippets/snippet_query.rb