Class: ArFinderForm::Attr::Like
- Defined in:
- lib/ar_finder_form/attr/like.rb
Constant Summary collapse
- MATCHERS =
{ :forward => '%s%%', :backward => '%%%s', :partial => '%%%s%%' }
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) ⇒ Like
constructor
A new instance of Like.
- #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
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
12 13 14 |
# File 'lib/ar_finder_form/attr/like.rb', line 12 def operator @operator end |
Instance Method Details
#build(context) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ar_finder_form/attr/like.rb', line 22 def build(context) return unless match?(context) context.add_condition( "#{column_name(context)} LIKE ?", @mathcer % form_value(context).to_s) end |
#setup ⇒ Object
18 19 20 |
# File 'lib/ar_finder_form/attr/like.rb', line 18 def setup client_class_eval("attr_accessor :#{name}") end |