Class: Sunspot::TextFieldSetup
- Inherits:
-
Object
- Object
- Sunspot::TextFieldSetup
- Defined in:
- sunspot/lib/sunspot/text_field_setup.rb
Overview
A TextFieldSetup encapsulates a regular (or composite) setup, and exposes the #field() method returning text fields instead of attribute fields.
Instance Method Summary (collapse)
-
- (Object) field(name)
Return a text field with the given name.
-
- (TextFieldSetup) initialize(setup)
constructor
:nodoc:.
Constructor Details
- (TextFieldSetup) initialize(setup)
:nodoc:
7 8 9 |
# File 'sunspot/lib/sunspot/text_field_setup.rb', line 7 def initialize(setup) @setup = setup end |
Instance Method Details
- (Object) field(name)
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 'sunspot/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 |