Module: MergeFilter
- Defined in:
- lib/merge_filter.rb,
lib/merge_filter/version.rb,
lib/merge_filter/undefined_filter.rb
Defined Under Namespace
Modules: ClassMethods
Classes: UndefinedFilter
Constant Summary
collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#filter ⇒ Object
Returns the value of attribute filter.
5
6
7
|
# File 'lib/merge_filter.rb', line 5
def filter
@filter
end
|
Class Method Details
.included(base) ⇒ Object
7
8
9
|
# File 'lib/merge_filter.rb', line 7
def self.included base
base.extend ClassMethods
end
|
Instance Method Details
#initialize(filter = {}) ⇒ Object
33
34
35
|
# File 'lib/merge_filter.rb', line 33
def initialize filter = {}
@filter = filter
end
|
#records ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/merge_filter.rb', line 37
def records
filter.inject(default_scope) do |scope, (key, value)|
if respond_to?(key)
scope.merge(__send__(key, value))
else
raise MergeFilter::UndefinedFilter, "There is no filter_by definition for #{key}."
end
end
end
|