Class: SaasPlatform::SearchService
- Inherits:
-
Object
- Object
- SaasPlatform::SearchService
- Defined in:
- app/services/saas_platform/search_service.rb
Instance Method Summary collapse
-
#initialize(account, query) ⇒ SearchService
constructor
A new instance of SearchService.
- #perform ⇒ Object
Constructor Details
#initialize(account, query) ⇒ SearchService
Returns a new instance of SearchService.
3 4 5 6 |
# File 'app/services/saas_platform/search_service.rb', line 3 def initialize(account, query) @account = account @query = query end |
Instance Method Details
#perform ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/saas_platform/search_service.rb', line 8 def perform return {} if @query.blank? ActsAsTenant.with_tenant(@account) do { users: SaasPlatform::User.search_by_name(@query).limit(5), products: SaasPlatform::Product.search_by_name(@query).limit(5), orders: SaasPlatform::Order.where(id: @query.to_i).limit(5) # Simple ID search for orders } end end |