Class: Upframework::BaseSearch
Defined Under Namespace
Modules: ExecuteWrapper
Constant Summary
collapse
- DEFAULT_PAGE =
1
- DEFAULT_PER_PAGE =
12
Instance Attribute Summary
Attributes inherited from BaseService
#errors
Instance Method Summary
collapse
#execute
Methods inherited from BaseService
#error?, #error_messages, #execute, #initialize, #post_initialize, run, #success?
Instance Method Details
#paginate_scope ⇒ Object
13
14
15
16
17
18
|
# File 'app/searches/upframework/base_search.rb', line 13
def paginate_scope
@model_scope = @model_scope.
page(@page || DEFAULT_PAGE).
per(@per_page || DEFAULT_PER_PAGE).
order(created_at: :desc)
end
|
#present_value?(field) ⇒ Boolean
20
21
22
|
# File 'app/searches/upframework/base_search.rb', line 20
def present_value?(field)
instance_variable_get("@#{field}").present?
end
|
#query(field) ⇒ Object
9
10
11
|
# File 'app/searches/upframework/base_search.rb', line 9
def query(field)
@model_scope = yield if present_value?(field)
end
|
#result ⇒ Object
5
6
7
|
# File 'app/searches/upframework/base_search.rb', line 5
def result
@model_scope
end
|