Commit cf204ab

mo <mo@mokhan.ca>
2019-05-09 21:49:44
extract a pageable concern
1 parent b780f09
Changed files (2)
app
controllers
app/controllers/concerns/pageable.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module Pageable
+  extend ActiveSupport::Concern
+
+  included do
+    def paginate(query)
+      Paginate.new(query, params)
+    end
+  end
+end
app/controllers/scim/v2/users_controller.rb
@@ -3,6 +3,7 @@
 module Scim
   module V2
     class UsersController < ::Scim::Controller
+      include Pageable
       rescue_from ActiveRecord::RecordNotFound do |_error|
         @resource_id = params[:id] if params[:id].present?
         render "record_not_found", status: :not_found
@@ -43,10 +44,6 @@ module Scim
         params.permit(:schemas, :userName, :locale, :timezone)
       end
 
-      def paginate(query)
-        Paginate.new(query, params)
-      end
-
       def repository(container = Spank::IOC)
         container.resolve(:user_repository)
       end