diff options
Diffstat (limited to 'app/finders/admin/plans_finder.rb')
-rw-r--r-- | app/finders/admin/plans_finder.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/finders/admin/plans_finder.rb b/app/finders/admin/plans_finder.rb new file mode 100644 index 00000000000..5ca4b61b25e --- /dev/null +++ b/app/finders/admin/plans_finder.rb @@ -0,0 +1,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 |