Class: Edgar::SearchPopup
- Inherits:
-
Search
- Object
- Search
- Edgar::SearchPopup
- Defined in:
- app/models/edgar/search_popup.rb
Overview
Search condition for popup
Instance Attribute Summary (collapse)
-
- (Object) col
Returns the value of attribute col.
-
- (Object) klass_str
Returns the value of attribute klass_str.
-
- (Object) val
Returns the value of attribute val.
Attributes inherited from Search
Instance Method Summary (collapse)
-
- (Object) conditions
implement to generate search-conditions.
-
- (SearchPopup) initialize(klass, hash = nil)
constructor
A new instance of SearchPopup.
- - (Object) validate_integer private
Methods inherited from Search
Constructor Details
- (SearchPopup) initialize(klass, hash = nil)
A new instance of SearchPopup
9 10 11 12 13 |
# File 'app/models/edgar/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
- (Object) col
Returns the value of attribute col
4 5 6 |
# File 'app/models/edgar/search_popup.rb', line 4 def col @col end |
- (Object) klass_str
Returns the value of attribute klass_str
4 5 6 |
# File 'app/models/edgar/search_popup.rb', line 4 def klass_str @klass_str end |
- (Object) val
Returns the value of attribute val
4 5 6 |
# File 'app/models/edgar/search_popup.rb', line 4 def val @val end |
Instance Method Details
- (Object) conditions
implement to generate search-conditions
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/edgar/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 |
- (Object) validate_integer (private)
34 35 36 37 38 39 40 41 42 |
# File 'app/models/edgar/search_popup.rb', line 34 def validate_integer case column_type(col) when :integer if val.present? && val !~ /^[\d\.\-]+$/ errors.add(:val, :not_an_integer) end else end end |