Method: Sunspot::TextFieldSetup#field

Defined in:
lib/sunspot/text_field_setup.rb

#field(name) ⇒ Object

Return a text field with the given name. Duck-type compatible with Setup and CompositeSetup, but return text fields instead.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sunspot/text_field_setup.rb', line 15

def field(name)
  fields = @setup.text_fields(name)
  if fields
    if fields.length == 1
      fields.first
    else
      raise(
        Sunspot::UnrecognizedFieldError,
        "The text field with name #{name} has incompatible configurations for the classes #{@setup.type_names.join(', ')}"
      )
    end
  end
end