Sha256: 99aa1ffc29e8d1dd396f069501af6bf3d0f489fc36335954876aa0736c45a526

Contents?: true

Size: 822 Bytes

Versions: 1

Compression:

Stored size: 822 Bytes

Contents

module Searchgasm
  module Condition
    class GreaterThanOrEqualTo < Base
      class << self
        def name_for_column(column)
          return unless comparable_column?(column)
          super
        end
        
        def aliases_for_column(column)
          column_names = [column.name]
          column_names << column.name.gsub(/_(at|on)$/, "") if datetime_column?(column) && column.name =~ /_(at|on)$/
          
          aliases = []
          column_names.each { |column_name| aliases += ["#{column_name}_gte", "#{column_name}_at_least"] }
          aliases << "#{column_names.last}_greater_than_or_equal_to" if column_names.size > 1
          aliases
        end
      end
      
      def to_conditions(value)
        ["#{quoted_table_name}.#{quoted_column_name} >= ?", value]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
searchgasm-1.2.2 lib/searchgasm/condition/greater_than_or_equal_to.rb