Sha256: b711db59842f2e53617d4cd61d74e6de69e7169779bfe8ce21f29b29f054c334

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

module Searchjoy
  class Search < ActiveRecord::Base
    belongs_to :convertable, polymorphic: true

    before_save :set_normalized_query

    def convert(convertable = nil)
      if !converted?
        self.converted_at = Time.now
        self.convertable = convertable
        save(validate: false)
      end
    end

    def converted?
      converted_at.present?
    end

    protected

    def set_normalized_query
      self.normalized_query = query.downcase if query
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
searchjoy-0.0.5 lib/searchjoy/search.rb