Class: WithFilters::FilterForm
- Inherits:
-
Object
- Object
- WithFilters::FilterForm
- Defined in:
- lib/with_filters/models/filter_form.rb
Instance Attribute Summary (collapse)
-
- (Object) actions
readonly
Returns the value of attribute actions.
-
- (Object) attrs
readonly
Returns the value of attribute attrs.
-
- (Object) filters
readonly
Returns the value of attribute filters.
-
- (Object) hidden_filters
readonly
Returns the value of attribute hidden_filters.
-
- (Object) param_namespace
readonly
Returns the value of attribute param_namespace.
-
- (Object) to_partial_path
readonly
Returns the value of attribute to_partial_path.
Instance Method Summary (collapse)
- - (Object) action(type, options = {})
- - (Object) hidden(name, options = {})
-
- (FilterForm) initialize(records, values = {}, options = {})
constructor
A new instance of FilterForm.
- - (Object) input(name, options = {})
- - (Object) input_range(name, options = {})
Constructor Details
- (FilterForm) initialize(records, values = {}, options = {})
A new instance of FilterForm
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/with_filters/models/filter_form.rb', line 8 def initialize(records, values = {}, = {}) @records = records @values = values @theme = .delete(:theme) @attrs = .reverse_merge(novalidate: 'novalidate', method: 'get') @to_partial_path = self.class.name.underscore @param_namespace = @records.with_filters_data[:param_namespace] @hidden_filters = [] @filters = [] @actions = [] end |
Instance Attribute Details
- (Object) actions (readonly)
Returns the value of attribute actions
3 4 5 |
# File 'lib/with_filters/models/filter_form.rb', line 3 def actions @actions end |
- (Object) attrs (readonly)
Returns the value of attribute attrs
3 4 5 |
# File 'lib/with_filters/models/filter_form.rb', line 3 def attrs @attrs end |
- (Object) filters (readonly)
Returns the value of attribute filters
3 4 5 |
# File 'lib/with_filters/models/filter_form.rb', line 3 def filters @filters end |
- (Object) hidden_filters (readonly)
Returns the value of attribute hidden_filters
3 4 5 |
# File 'lib/with_filters/models/filter_form.rb', line 3 def hidden_filters @hidden_filters end |
- (Object) param_namespace (readonly)
Returns the value of attribute param_namespace
3 4 5 |
# File 'lib/with_filters/models/filter_form.rb', line 3 def param_namespace @param_namespace end |
- (Object) to_partial_path (readonly)
Returns the value of attribute to_partial_path
3 4 5 |
# File 'lib/with_filters/models/filter_form.rb', line 3 def to_partial_path @to_partial_path end |
Instance Method Details
- (Object) action(type, options = {})
60 61 62 |
# File 'lib/with_filters/models/filter_form.rb', line 60 def action(type, = {}) @actions.push(WithFilters::Action.new(type, )) end |
- (Object) hidden(name, options = {})
25 26 27 28 29 |
# File 'lib/with_filters/models/filter_form.rb', line 25 def hidden(name, = {}) .merge!(as: :hidden) input(name, ) end |
- (Object) input(name, options = {})
35 36 37 38 39 40 41 42 43 |
# File 'lib/with_filters/models/filter_form.rb', line 35 def input(name, = {}) [:as] = find_as(name, [:collection]) unless [:as] .merge!(theme: @theme) as = [:as] filter = WithFilters::Filter.create(name, self.param_namespace, @values[name.to_s], ) (as == :hidden ? @hidden_filters : @filters).push(filter) end |
- (Object) input_range(name, options = {})
49 50 51 52 53 54 |
# File 'lib/with_filters/models/filter_form.rb', line 49 def input_range(name, = {}) [:as] = find_as(name, [:collection]) unless [:as] .merge!(theme: @theme) @filters.push(WithFilters::Filter.create_range(name, self.param_namespace, @values[name.to_s] || {}, )) end |