Class: QueryReport::FilterModule::Filter
- Inherits:
-
Object
- Object
- QueryReport::FilterModule::Filter
- Defined in:
- lib/query_report/filter.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#comparators ⇒ Object
readonly
Returns the value of attribute comparators.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #custom? ⇒ Boolean
- #has_default? ⇒ Boolean
-
#initialize(params, column, options, &block) ⇒ Filter
constructor
- Initializes filter with the proper parameters Params:
params -
The params from the http request.
- Initializes filter with the proper parameters Params:
- #params_key ⇒ Object
- #search_keys ⇒ Object
Constructor Details
#initialize(params, column, options, &block) ⇒ Filter
Initializes filter with the proper parameters Params:
params-
The params from the http request
69 70 71 72 73 |
# File 'lib/query_report/filter.rb', line 69 def initialize(params, column, , &block) @params, @column, @options, @comparators, @block = params, column, , [], block @type = .kind_of?(String) ? : [:type] generate_comparators end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
64 65 66 |
# File 'lib/query_report/filter.rb', line 64 def block @block end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
64 65 66 |
# File 'lib/query_report/filter.rb', line 64 def column @column end |
#comparators ⇒ Object (readonly)
Returns the value of attribute comparators.
64 65 66 |
# File 'lib/query_report/filter.rb', line 64 def comparators @comparators end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
64 65 66 |
# File 'lib/query_report/filter.rb', line 64 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
64 65 66 |
# File 'lib/query_report/filter.rb', line 64 def params @params end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
64 65 66 |
# File 'lib/query_report/filter.rb', line 64 def type @type end |
Class Method Details
.supported_types ⇒ Object
75 76 77 |
# File 'lib/query_report/filter.rb', line 75 def self.supported_types [:date, :datetime, :text, :boolean] end |
Instance Method Details
#custom? ⇒ Boolean
85 86 87 |
# File 'lib/query_report/filter.rb', line 85 def custom? (@block || @options[:manual]) ? true : false end |
#has_default? ⇒ Boolean
93 94 95 |
# File 'lib/query_report/filter.rb', line 93 def has_default? @comparators.any?(&:has_default?) end |
#params_key ⇒ Object
97 98 99 |
# File 'lib/query_report/filter.rb', line 97 def params_key custom? ? :custom_search : :q end |
#search_keys ⇒ Object
89 90 91 |
# File 'lib/query_report/filter.rb', line 89 def search_keys @comparators.collect(&:search_key) end |