Sha256: 7dd196f9b6fe247539e413d81dc77240aa0286f6aeeb3e3590a519e7ac964813

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

require 'elasticsearch_autocomplete/version'
require 'elasticsearch_autocomplete/analyzers'
require 'elasticsearch_autocomplete/model_addition'
require 'elasticsearch_autocomplete/railtie' if defined? Rails

module ElasticsearchAutocomplete
  mattr_accessor :defaults

  def self.default_index_prefix
    Rails.application.class.name.split('::').first.downcase if Object.const_defined?('Rails')
  end

  self.defaults = {:attr => :name, :localized => false, :mode => :word, :index_prefix => default_index_prefix}

  MODES = {
      :word => {:base => 'ac', :word => 'ac_word'},
      :phrase => {:base => 'ac'},
      :full => {:base => 'ac', :full => 'ac_full'}
  }

  def self.val_to_array(val, zero=false)
    return [] unless val
    a = val.is_a?(Array) ? val : val.to_s.split(',').map(&:to_i)
    zero ? a : a.reject(&:zero?)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elasticsearch_autocomplete-0.0.2 lib/elasticsearch_autocomplete.rb
elasticsearch_autocomplete-0.0.1 lib/elasticsearch_autocomplete.rb