lib/admino/query/configuration.rb in admino-0.0.8 vs lib/admino/query/configuration.rb in admino-0.0.9
- old
+ new
@@ -18,15 +18,24 @@
end
class FilterGroup
attr_reader :name
attr_reader :scopes
+ attr_reader :options
- def initialize(name, scopes)
+ def initialize(name, scopes, options = {})
+ options.symbolize_keys!
+ options.assert_valid_keys(:include_empty_scope)
+
@name = name.to_sym
@scopes = scopes.map(&:to_sym)
+ @options = options
end
+
+ def include_empty_scope?
+ @options.fetch(:include_empty_scope) { false }
+ end
end
class Sorting
attr_reader :scopes
attr_reader :default_scope
@@ -62,11 +71,11 @@
SearchField.new(name, options).tap do |search_field|
self.search_fields << search_field
end
end
- def add_filter_group(name, scopes)
- FilterGroup.new(name, scopes).tap do |filter_group|
+ def add_filter_group(name, scopes, options = {})
+ FilterGroup.new(name, scopes, options).tap do |filter_group|
self.filter_groups << filter_group
end
end
def add_sorting_scopes(scopes, options = {})