Sha256: dcf739a77e971d998c1f360ae0ad86ac42cbad7b4418fe6e26bf20dd863315a0

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

module Searchgasm
  module Condition
    class LessThan < 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}_lt", "#{column_name}_before"] }
          aliases << "#{column_names.last}_less_than" 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/less_than.rb