Sha256: 63247545fd80ef930b5edb4481ac27827d0871c75a3ee11326817ed136c556da

Contents?: true

Size: 479 Bytes

Versions: 5

Compression:

Stored size: 479 Bytes

Contents

module Flare
  class IndexBuilder
    attr_reader :fields

    def initialize(&block)
      @fields = []
      self.instance_eval(&block) if block_given?
    end

    def index
      { :fields => @fields }
    end

    protected
      def field(*args)
        field, options = args.first, args.extract_options!
        @fields << {
          :source => field, 
          :name => options[:as] || field, 
          :boost => options[:boost] || nil
          }
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flare-1.1.0 lib/flare/index_builder.rb
flare-1.0.2 lib/flare/index_builder.rb
flare-1.0.1 lib/flare/index_builder.rb
flare-1.0.0 lib/flare/index_builder.rb
flare-0.0.1 lib/flare/index_builder.rb