Method: Sunspot::AttributeField#initialize

Defined in:
lib/sunspot/field.rb

#initialize(name, type, options = {}) ⇒ AttributeField

:nodoc:

Raises:

  • (ArgumentError)


125
126
127
128
129
130
131
132
133
134
135
# File 'lib/sunspot/field.rb', line 125

def initialize(name, type, options = {})
  super(name, type, options)
  @multiple = !!options.delete(:multiple)
  @reference =
    if (reference = options.delete(:references)).respond_to?(:name)
      reference.name
    elsif reference.respond_to?(:to_sym)
      reference.to_sym
    end
  raise ArgumentError, "Unknown field option #{options.keys.first.inspect} provided for field #{name.inspect}" unless options.empty?
end