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 lib/sunspot/text_field_setup.rb
sunspot-2.0.0.pre.130115 lib/sunspot/text_field_setup.rb
gojee-sunspot-2.0.5 lib/sunspot/text_field_setup.rb
sunspot-2.0.0.pre.120925 lib/sunspot/text_field_setup.rb
sunspot_solr-2.0.0.pre.120924 sunspot/lib/sunspot/text_field_setup.rb
sunspot_rails-2.0.0.pre.120924 sunspot/lib/sunspot/text_field_setup.rb
sunspot-2.0.0.pre.120924 sunspot/lib/sunspot/text_field_setup.rb
gojee-sunspot-2.0.4 lib/sunspot/text_field_setup.rb
gojee-sunspot-2.0.2 lib/sunspot/text_field_setup.rb
sunspot-2.0.0.pre.120720 lib/sunspot/text_field_setup.rb
sunspot-1.3.3 lib/sunspot/text_field_setup.rb
sunspot-1.3.2 lib/sunspot/text_field_setup.rb
sunspot-2.0.0.pre.120417 lib/sunspot/text_field_setup.rb
sunspot-2.0.0.pre.120415 lib/sunspot/text_field_setup.rb
sunspot-1.3.1 lib/sunspot/text_field_setup.rb
erichummel-sunspot-2.0.0.pre.111215d lib/sunspot/text_field_setup.rb
erichummel-sunspot-2.0.0.pre.111215c lib/sunspot/text_field_setup.rb
erichummel-sunspot-2.0.0.pre.111215b lib/sunspot/text_field_setup.rb
erichummel-sunspot-2.0.0.pre.111215a lib/sunspot/text_field_setup.rb
erichummel-sunspot-2.0.0.pre.111215 lib/sunspot/text_field_setup.rb