Sha256: d74ab31323afb6863fe3cdeca8bb02929ff7f2d5e2303e431dbf2da2a5c63ae1

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module OpenStax
  module Accounts
    module Dev
      class UsersSearch

        lev_handler transaction: :no_transaction
        
        paramify :search do
          attribute :search_type, type: String
          validates :search_type, presence: true,
                                  inclusion: { in: %w(Name Username Any),
                                               message: "is not valid" }

          attribute :search_terms, type: String
          validates :search_terms, presence: true                               
        end

        uses_routine OpenStax::Accounts::SearchUsers, 
                     as: :search_users,
                     translations: { outputs: {type: :verbatim} }

      protected

        def authorized?
          !Rails.env.production? || caller.is_administrator?
        end

        def handle
          terms = search_params.search_terms
          type = search_params.search_type

          run(:search_users, terms, type.downcase.to_sym)
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openstax_accounts-0.3.0 app/handlers/openstax/accounts/dev/users_search.rb
openstax_accounts-0.3 app/handlers/openstax/accounts/dev/users_search.rb
openstax_accounts-0.2.1 app/handlers/openstax/accounts/dev/users_search.rb
openstax_accounts-0.2.0 app/handlers/openstax/accounts/dev/users_search.rb
openstax_accounts-0.1.0 app/handlers/openstax/accounts/dev/users_search.rb