Sha256: 56ad7a0fcf36075a6314c6fb48b1c0ebbc28c82c431ab769bb41ca6a3273a888

Contents?: true

Size: 798 Bytes

Versions: 83

Compression:

Stored size: 798 Bytes

Contents

module Sunspot
  # 
  # A TextFieldSetup encapsulates a regular (or composite) setup, and exposes
  # the #field() method returning text fields instead of attribute fields.
  #
  class TextFieldSetup #:nodoc:
    def initialize(setup)
      @setup = setup
    end

    # 
    # Return a text field with the given name. Duck-type compatible with
    # Setup and CompositeSetup, but return text fields instead.
    #
    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
  end
end

Version data entries

83 entries across 83 versions & 15 rubygems

Version Path
sunspot-2.0.0.pre.111215 lib/sunspot/text_field_setup.rb
cb_sunspot-2.0.0.pre.5 lib/sunspot/text_field_setup.rb
cb_sunspot-2.0.0.pre.3 lib/sunspot/text_field_setup.rb
cb_sunspot-2.0.0.pre3 lib/sunspot/text_field_setup.rb
sunspot-1.3.0 lib/sunspot/text_field_setup.rb
pduey-sunspot-1.2.1.1 lib/sunspot/text_field_setup.rb
sunspot-1.3.0.rc6 lib/sunspot/text_field_setup.rb
erichummel-sunspot-1.2.1g lib/sunspot/text_field_setup.rb
erichummel-sunspot-1.2.1f lib/sunspot/text_field_setup.rb
erichummel-sunspot-1.2.1b lib/sunspot/text_field_setup.rb
erichummel-sunspot-1.2.1a lib/sunspot/text_field_setup.rb
erichummel-sunspot-1.2.1 lib/sunspot/text_field_setup.rb
lisausa-sunspot-1.2.1.1 lib/sunspot/text_field_setup.rb
lisausa-sunspot-1.2.1 lib/sunspot/text_field_setup.rb
sunspot_rbg-1.3.1 lib/sunspot/text_field_setup.rb
sunspot_rbg-1.3.0 lib/sunspot/text_field_setup.rb
ruben-sunspot-1.1.4 lib/sunspot/text_field_setup.rb
ruben-sunspot-1.1.3 lib/sunspot/text_field_setup.rb
ruben-sunspot-1.1.2 lib/sunspot/text_field_setup.rb
sunspot-1.2.1 lib/sunspot/text_field_setup.rb