Files
postter/app/services/posts_query_resolver_service.rb
João Victor Geonizeli bf3253dc9e add posts scope filter
2022-02-28 11:22:37 -03:00

22 lines
412 B
Ruby

class PostsQueryResolverService
attr_reader :filter, :current_user
def initialize(filter, current_user)
@filter = filter
@current_user = current_user
end
def self.call(filter, current_user)
new(filter, current_user).call
end
def call
scope = Post.all
if filter[:scope] == 'follows' && current_user
scope = scope.by_user_follows(current_user)
end
scope
end
end