Class: ArFinderForm::Attr::RangeAttrs
- Defined in:
- lib/ar_finder_form/attr/range_attrs.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
Attributes inherited from Base
#array_separator, #column, #name, #nil_available, #options
Instance Method Summary collapse
- #build(context) ⇒ Object
-
#initialize(column, name, options) ⇒ RangeAttrs
constructor
A new instance of RangeAttrs.
- #setup ⇒ Object
Methods inherited from Base
#client_class_eval, #column_name, #column_type_cast, #form_value, #form_value_array, #match?, #nil_available?, #table
Constructor Details
#initialize(column, name, options) ⇒ RangeAttrs
Returns a new instance of RangeAttrs.
7 8 9 10 11 12 13 14 |
# File 'lib/ar_finder_form/attr/range_attrs.rb', line 7 def initialize(column, name, ) super(column, name, ) range = [:range] || {} min_def = {:operator => '>='}.update(range[:min] || [:min] || {}) max_def = {:operator => '<='}.update(range[:max] || [:max] || {}) @min = Simple.new(column, min_def[:attr] || "#{name}_min", min_def) @max = Simple.new(column, max_def[:attr] || "#{name}_max", max_def) end |
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
6 7 8 |
# File 'lib/ar_finder_form/attr/range_attrs.rb', line 6 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
6 7 8 |
# File 'lib/ar_finder_form/attr/range_attrs.rb', line 6 def min @min end |
Instance Method Details
#build(context) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ar_finder_form/attr/range_attrs.rb', line 21 def build(context) sub_context = context.new_sub_context(:connector => 'AND') @min.build(sub_context) @max.build(sub_context) context.merge(sub_context) end |
#setup ⇒ Object
16 17 18 19 |
# File 'lib/ar_finder_form/attr/range_attrs.rb', line 16 def setup @min.setup @max.setup end |