Module: Sift
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/sift/filter_validator.rb,
lib/sift/sort.rb,
lib/sift/filter.rb,
lib/procore-sift.rb,
lib/sift/version.rb,
lib/sift/filtrator.rb,
lib/sift/parameter.rb,
lib/sift/value_parser.rb,
lib/sift/scope_handler.rb,
lib/sift/where_handler.rb,
lib/sift/type_validator.rb,
lib/sift/subset_comparator.rb
Overview
Here be dragons: there are two forms of metaprogramming in this file instance variables are being dynamically set based on the param name and we are class evaling ‘validates` to create dynamic validations based on the filters being validated.
Defined Under Namespace
Classes: Filter, FilterValidator, Filtrator, Parameter, ScopeHandler, Sort, SubsetComparator, TypeValidator, ValueParser, WhereHandler
Constant Summary
collapse
- VERSION =
"0.13.0".freeze
Instance Method Summary
collapse
Instance Method Details
#filter_errors ⇒ Object
33
34
35
|
# File 'lib/procore-sift.rb', line 33
def filter_errors
filter_validator.errors.messages
end
|
#filter_params ⇒ Object
21
22
23
|
# File 'lib/procore-sift.rb', line 21
def filter_params
params.fetch(:filters, {})
end
|
#filters_valid? ⇒ Boolean
29
30
31
|
# File 'lib/procore-sift.rb', line 29
def filters_valid?
filter_validator.valid?
end
|
#filtrate(collection) ⇒ Object
17
18
19
|
# File 'lib/procore-sift.rb', line 17
def filtrate(collection)
Filtrator.filter(collection, params, filters)
end
|
#sort_params ⇒ Object
25
26
27
|
# File 'lib/procore-sift.rb', line 25
def sort_params
params.fetch(:sort, "").split(",") if filters.any? { |filter| filter.is_a?(Sort) }
end
|