class ThinkingSphinx::AttributeTypes
Public Class Methods
call()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 4 def self.call @call ||= new.call end
reset()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 8 def self.reset @call = nil end
Public Instance Methods
call()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 12 def call return {} unless File.exist?(configuration_file) realtime_indices.each { |index| map_types_with_prefix index, :rt, [:uint, :bigint, :float, :timestamp, :string, :bool, :json] index.rt_attr_multi.each { |name| attributes[name] << :uint } index.rt_attr_multi_64.each { |name| attributes[name] << :bigint } } plain_sources.each { |source| map_types_with_prefix source, :sql, [:uint, :bigint, :float, :timestamp, :string, :bool, :json] source.sql_attr_str2ordinal { |name| attributes[name] << :uint } source.sql_attr_str2wordcount { |name| attributes[name] << :uint } source.sql_attr_multi.each { |setting| type, name, *ignored = setting.split(/\s+/) attributes[name] << type.to_sym } } attributes.values.each &:uniq! attributes end
Private Instance Methods
attributes()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 41 def attributes @attributes ||= Hash.new { |hash, key| hash[key] = [] } end
configuration()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 45 def configuration @configuration ||= Riddle::Configuration.parse!( File.read(configuration_file) ) end
configuration_file()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 51 def configuration_file ThinkingSphinx::Configuration.instance.configuration_file end
map_types_with_prefix(object, prefix, types)
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 55 def map_types_with_prefix(object, prefix, types) types.each do |type| object.public_send("#{prefix}_attr_#{type}").each do |name| attributes[name] << type end end end
plain_sources()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 63 def plain_sources configuration.indices.select { |index| index.type == 'plain' || index.type.nil? }.collect(&:sources).flatten end
realtime_indices()
click to toggle source
# File lib/thinking_sphinx/attribute_types.rb, line 69 def realtime_indices configuration.indices.select { |index| index.type == 'rt' } end