Class: ArFinderForm::Attr::Simple
- Defined in:
- lib/ar_finder_form/attr/simple.rb
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Attributes inherited from Base
#array_separator, #column, #name, #nil_available, #options
Instance Method Summary collapse
- #build(context) ⇒ Object
-
#initialize(column, name, options) ⇒ Simple
constructor
A new instance of Simple.
- #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) ⇒ Simple
Returns a new instance of Simple.
6 7 8 9 |
# File 'lib/ar_finder_form/attr/simple.rb', line 6 def initialize(column, name, ) super(column, name, ) @operator = .delete(:operator).to_s.downcase.to_sym end |
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
5 6 7 |
# File 'lib/ar_finder_form/attr/simple.rb', line 5 def operator @operator end |
Instance Method Details
#build(context) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ar_finder_form/attr/simple.rb', line 15 def build(context) return unless match?(context) case operator when :in then context.add_condition("#{column_name(context)} IN (?)", form_value_array(context)) else context.add_condition( "#{column_name(context)} #{operator} ?", form_value(context)) end end |
#setup ⇒ Object
11 12 13 |
# File 'lib/ar_finder_form/attr/simple.rb', line 11 def setup client_class_eval("attr_accessor :#{name}") end |