Class: Searchgasm::Condition::GreaterThan

Inherits:
Base
  • Object
show all
Defined in:
lib/searchgasm/condition/greater_than.rb

Instance Attribute Summary

Attributes inherited from Base

#column, #klass

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases_for_klass, comparable_column?, condition_name, #condition_name, #explicitly_set_value=, #explicitly_set_value?, ignore_blanks?, #initialize, #name, name_for_klass, #quote_column_name, #quote_table_name, #quoted_column_name, #quoted_table_name, #sanitize, string_column?, type_cast_value?, #value, #value=

Constructor Details

This class inherits a constructor from Searchgasm::Condition::Base

Class Method Details

.aliases_for_column(column) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/searchgasm/condition/greater_than.rb', line 10

def aliases_for_column(column)
  column_names = [column.name]
  column_names << column.name.gsub(/_at$/, "") if [:datetime, :timestamp, :time, :date].include?(column.type) && column.name =~ /_at$/
  
  aliases = []
  column_names.each { |column_name| aliases += ["#{column_name}_gt", "#{column_name}_after"] }
  aliases
end

.name_for_column(column) ⇒ Object



5
6
7
8
# File 'lib/searchgasm/condition/greater_than.rb', line 5

def name_for_column(column)
  return unless comparable_column?(column)
  super
end

Instance Method Details

#to_conditions(value) ⇒ Object



20
21
22
# File 'lib/searchgasm/condition/greater_than.rb', line 20

def to_conditions(value)
  ["#{quoted_table_name}.#{quoted_column_name} > ?", value]
end