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.7.1 lib/sunspot/text_field_setup.rb
sunspot-2.7.0 lib/sunspot/text_field_setup.rb
sunspot-2.6.0 lib/sunspot/text_field_setup.rb
sunspot-2.5.0 lib/sunspot/text_field_setup.rb
sunspot-2.4.0 lib/sunspot/text_field_setup.rb
sunspot-2.3.0 lib/sunspot/text_field_setup.rb
sunspot-2.2.8 lib/sunspot/text_field_setup.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/sunspot-2.2.7/lib/sunspot/text_field_setup.rb
sunspot-2.2.7 lib/sunspot/text_field_setup.rb
sunspot-2.2.6 lib/sunspot/text_field_setup.rb
sunspot-2.2.5 lib/sunspot/text_field_setup.rb
sunspot-2.2.4 lib/sunspot/text_field_setup.rb
sunspot-2.2.3 lib/sunspot/text_field_setup.rb
sunspot-2.2.2 lib/sunspot/text_field_setup.rb
sunspot-2.2.1 lib/sunspot/text_field_setup.rb
sunspot-2.2.0 lib/sunspot/text_field_setup.rb
benjaminkrause-sunspot-0.9.7 lib/sunspot/text_field_setup.rb
benjaminkrause-sunspot-0.9.8 lib/sunspot/text_field_setup.rb
sunspot-2.1.1 lib/sunspot/text_field_setup.rb
sunspot-2.1.0 lib/sunspot/text_field_setup.rb