Class: Stall::ProductsSearchService

Inherits:
BaseService show all
Defined in:
app/services/stall/products_search_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(products, params) ⇒ ProductsSearchService



6
7
8
9
# File 'app/services/stall/products_search_service.rb', line 6

def initialize(products, params)
  @products = products
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'app/services/stall/products_search_service.rb', line 3

def params
  @params
end

#productsObject (readonly)

Returns the value of attribute products.



3
4
5
# File 'app/services/stall/products_search_service.rb', line 3

def products
  @products
end

#searchObject (readonly)

Returns the value of attribute search.



3
4
5
# File 'app/services/stall/products_search_service.rb', line 3

def search
  @search
end

Instance Method Details

#callObject



11
12
13
# File 'app/services/stall/products_search_service.rb', line 11

def call
  @search = products.ransack(params[:search])
end

#formObject

Returns the value of attribute search.



4
5
6
# File 'app/services/stall/products_search_service.rb', line 4

def search
  @search
end

#recordsObject



19
20
21
# File 'app/services/stall/products_search_service.rb', line 19

def records
  search.result.distinct
end