summaryrefslogtreecommitdiff
path: root/app/finders/admin/plans_finder.rb
blob: 5ca4b61b25ee784ff91b06e148b7297f628c8b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module Admin
  class PlansFinder
    attr_reader :params

    def initialize(params = {})
      @params = params
    end

    def execute
      plans = Plan.all
      by_name(plans)
    end

    private

    def by_name(plans)
      return plans unless params[:name]

      Plan.find_by(name: params[:name])  # rubocop: disable CodeReuse/ActiveRecord
    end
  end
end