Class: Edgarj::SearchPopup
- Defined in:
- app/models/edgarj/search_popup.rb
Overview
Search condition for popup
Instance Attribute Summary collapse
-
#col ⇒ Object
Returns the value of attribute col.
-
#klass_str ⇒ Object
Returns the value of attribute klass_str.
-
#val ⇒ Object
Returns the value of attribute val.
Attributes inherited from Search
Instance Method Summary collapse
-
#conditions ⇒ Object
implement to generate search-conditions.
-
#initialize(klass, hash = nil) ⇒ SearchPopup
constructor
A new instance of SearchPopup.
Methods inherited from Search
Constructor Details
#initialize(klass, hash = nil) ⇒ SearchPopup
Returns a new instance of SearchPopup.
9 10 11 12 13 |
# File 'app/models/edgarj/search_popup.rb', line 9 def initialize(klass, hash = nil) super(klass) @col = hash ? hash[:col] : nil @val = hash ? hash[:val] : nil end |
Instance Attribute Details
#col ⇒ Object
Returns the value of attribute col.
4 5 6 |
# File 'app/models/edgarj/search_popup.rb', line 4 def col @col end |
#klass_str ⇒ Object
Returns the value of attribute klass_str.
4 5 6 |
# File 'app/models/edgarj/search_popup.rb', line 4 def klass_str @klass_str end |
#val ⇒ Object
Returns the value of attribute val.
4 5 6 |
# File 'app/models/edgarj/search_popup.rb', line 4 def val @val end |
Instance Method Details
#conditions ⇒ Object
implement to generate search-conditions
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/edgarj/search_popup.rb', line 16 def conditions return ['1=0'] if !valid? if @val.blank? [] else # FIXME: assume type is just string op = '=?' val = @val if val =~ /\*$/ op = ' like ?' val = @val.gsub(/\*/, '%') end ["#{@col}#{op}", val] end end |