Class: QueryHelper::Filter
- Inherits:
-
Object
- Object
- QueryHelper::Filter
- Defined in:
- lib/query_helper/filter.rb
Instance Attribute Summary collapse
-
#aggregate ⇒ Object
Returns the value of attribute aggregate.
-
#bind_variable ⇒ Object
Returns the value of attribute bind_variable.
-
#comparate ⇒ Object
Returns the value of attribute comparate.
-
#criterion ⇒ Object
Returns the value of attribute criterion.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#operator_code ⇒ Object
Returns the value of attribute operator_code.
-
#qualify_clause ⇒ Object
Returns the value of attribute qualify_clause.
Instance Method Summary collapse
-
#initialize(operator_code:, criterion:, comparate:, aggregate: false, qualify_clause: false) ⇒ Filter
constructor
A new instance of Filter.
- #sql_string ⇒ Object
Constructor Details
#initialize(operator_code:, criterion:, comparate:, aggregate: false, qualify_clause: false) ⇒ Filter
Returns a new instance of Filter.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/query_helper/filter.rb', line 8 def initialize( operator_code:, criterion:, comparate:, aggregate: false, qualify_clause: false ) @operator_code = operator_code @criterion = criterion # Converts to a string to be inserted into sql. @comparate = comparate @aggregate = aggregate @qualify_clause = qualify_clause @bind_variable = ('a'..'z').to_a.shuffle[0,20].join.to_sym translate_operator_code() mofify_criterion() modify_comparate() validate_criterion() end |
Instance Attribute Details
#aggregate ⇒ Object
Returns the value of attribute aggregate.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def aggregate @aggregate end |
#bind_variable ⇒ Object
Returns the value of attribute bind_variable.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def bind_variable @bind_variable end |
#comparate ⇒ Object
Returns the value of attribute comparate.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def comparate @comparate end |
#criterion ⇒ Object
Returns the value of attribute criterion.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def criterion @criterion end |
#operator ⇒ Object
Returns the value of attribute operator.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def operator @operator end |
#operator_code ⇒ Object
Returns the value of attribute operator_code.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def operator_code @operator_code end |
#qualify_clause ⇒ Object
Returns the value of attribute qualify_clause.
6 7 8 |
# File 'lib/query_helper/filter.rb', line 6 def qualify_clause @qualify_clause end |
Instance Method Details
#sql_string ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/query_helper/filter.rb', line 28 def sql_string case operator_code when "in", "notin" "#{comparate} #{operator} (:#{bind_variable})" when "null" "#{comparate} #{operator}" else "#{comparate} #{operator} :#{bind_variable}" end end |