Class: Lims::Core::Persistence::ComparisonFilter
- Includes:
- Resource
- Defined in:
- lib/lims-core/persistence/comparison_filter.rb
Overview
Filter performing a comparison between the resource field’s value and a given value. Key being the name of the resource’s field and the value is a Hash. The key of the hash is a comparison operator and the value is the given value the filter do the comparison against.
“model”: “kit”, “criteria”: {
"comparison": {
"expires": {
">=": "2013-04-24"
}
}
}
Will look for all kits expires after the given date (“2013-04-24”).
Constant Summary collapse
- NOT_IN_ROOT =
1
Instance Method Summary collapse
- #call(persistor) ⇒ Object
-
#initialize(criteria) ⇒ ComparisonFilter
constructor
For Sequel, keys needs to be a Symbol to be seen as column.
Methods included from Resource
Methods included from SubclassTracker
Constructor Details
#initialize(criteria) ⇒ ComparisonFilter
For Sequel, keys needs to be a Symbol to be seen as column. String are seen as ‘value’
35 36 37 38 39 |
# File 'lib/lims-core/persistence/comparison_filter.rb', line 35 def initialize(criteria) criteria = { :criteria => criteria } unless criteria.include?(:criteria) criteria[:criteria].rekey!{ |k| k.to_sym } super(criteria) end |
Instance Method Details
#call(persistor) ⇒ Object
41 42 43 |
# File 'lib/lims-core/persistence/comparison_filter.rb', line 41 def call(persistor) persistor.comparison_filter(criteria[:comparison]) end |