Module: Babik::QuerySet::Filterable
- Included in:
- AbstractBase
- Defined in:
- lib/babik/queryset/mixins/filterable.rb
Overview
Functionality related to the DELETE operation
Instance Method Summary collapse
-
#exclude!(filter) ⇒ QuerySet
Exclude objects according to some criteria.
-
#filter!(filter) ⇒ QuerySet
Select objects according to some criteria.
-
#get(filter) ⇒ ActiveRecord::Base
Get an single element.
Instance Method Details
#exclude!(filter) ⇒ QuerySet
Exclude objects according to some criteria.
9 10 11 12 |
# File 'lib/babik/queryset/mixins/filterable.rb', line 9 def exclude!(filter) _filter(filter, 'exclusion') self end |
#filter!(filter) ⇒ QuerySet
Select objects according to some criteria.
18 19 20 21 |
# File 'lib/babik/queryset/mixins/filterable.rb', line 18 def filter!(filter) _filter(filter, 'inclusion') self end |
#get(filter) ⇒ ActiveRecord::Base
Get an single element
30 31 32 33 34 35 36 |
# File 'lib/babik/queryset/mixins/filterable.rb', line 30 def get(filter) result_ = self.filter(filter).all result_count = result_.count raise 'Does not exist' if result_count.zero? raise 'Multiple objects returned' if result_count > 1 result_.first end |